diff --git a/anndata/_core/index.py b/anndata/_core/index.py index 92c4eb07d..fe3645b04 100644 --- a/anndata/_core/index.py +++ b/anndata/_core/index.py @@ -116,15 +116,18 @@ def unpack_index(index: Index) -> Tuple[Index1D, Index1D]: @singledispatch -def _subset(a: Union[np.ndarray, pd.DataFrame], subset_idx: Index): +def _subset(a: np.ndarray, subset_idx: Index): # Select as combination of indexes, not coordinates # Correcting for indexing behaviour of np.ndarray if all(isinstance(x, cabc.Iterable) for x in subset_idx): subset_idx = np.ix_(*subset_idx) - if isinstance(a, ZarrArray): - return a.oindex[subset_idx] return a[subset_idx] +@_subset.register(ZarrArray) +def _subset_zarr(a: ZarrArray, subset_idx: Index): + if all(isinstance(x, cabc.Iterable) for x in subset_idx): + subset_idx = np.ix_(*subset_idx) + return a.oindex[subset_idx] @_subset.register(DaskArray) def _subset_dask(a: DaskArray, subset_idx: Index):