diff --git a/anndata/core/anndata.py b/anndata/core/anndata.py index 6cf5f7f8d..f3a9fe8fe 100644 --- a/anndata/core/anndata.py +++ b/anndata/core/anndata.py @@ -385,7 +385,8 @@ def var_vector(self, k: str) -> np.ndarray: if k in self.var: return self.var[k].values else: - a = self[k, :].X + idx = self._normalize_indices((k, slice(None))) + a = self.X[idx] if issparse(a): a = a.toarray() return np.ravel(a) @@ -409,7 +410,8 @@ def obs_vector(self, k: str) -> np.ndarray: A one dimensional nd array, with values for each obs in the same order as `.obs_names`. """ - a = self[:, k].X + idx = self._normalize_indices((slice(None), k)) + a = self.X[idx] if issparse(a): a = a.toarray() return np.ravel(a)