Skip to content

Commit

Permalink
Fix bugs in accessor methods (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkanche authored Jan 26, 2024
1 parent bd52543 commit 07348ef
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/singlecellexperiment/SingleCellExperiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def reduced_dim(self, dimension: Union[str, int]) -> Any:
if dimension < 0:
raise IndexError("Index cannot be negative.")

if dimension > len(self.assay_names):
if dimension > len(self.reduced_dim_names):
raise IndexError("Index greater than the number of reduced dimensions.")

return self._reduced_dims[self.reduced_dim_names[dimension]]
Expand Down Expand Up @@ -680,15 +680,19 @@ def alternative_experiment(self, name: Union[str, int]) -> Any:
if name < 0:
raise IndexError("Index cannot be negative.")

if name > len(self.assay_names):
raise IndexError("Index greater than the number of reduced dimensions.")
if name > len(self.alternative_experiment_names):
raise IndexError(
"Index greater than the number of alternative experiments."
)

return self.alternative_experiments[self.alternative_experiment_names[name]]
return self._alternative_experiments[
self.alternative_experiment_names[name]
]
elif isinstance(name, str):
if name not in self.reduced_dim:
raise AttributeError(f"Reduced dimension: {name} does not exist.")
if name not in self._alternative_experiments:
raise AttributeError(f"Alternative experiment: {name} does not exist.")

return self.alternative_experiments[name]
return self._alternative_experiments[name]

raise TypeError(f"'name' must be a string or integer, provided '{type(name)}'.")

Expand Down Expand Up @@ -917,7 +921,7 @@ def get_slice(

new_row_ranges = None
if slicer.row_indices != slice(None):
new_row_ranges = self.row_ranges[slicer.row_indices]
new_row_ranges = self._row_ranges[slicer.row_indices]

new_reduced_dims = {}
for rdim, rmat in self._reduced_dims.items():
Expand Down

0 comments on commit 07348ef

Please sign in to comment.