Skip to content

Commit

Permalink
Fix access to raw.X by .raw.{obs,var}_vector
Browse files Browse the repository at this point in the history
Previously had relied on subsetting the entire object to get vector of X. Now just normalizes index.
Also stops throwing warning about changing behaviour. Whoops. scverse#171 (comment)
  • Loading branch information
ivirshup committed Jul 7, 2019
1 parent 34e8616 commit e102b98
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions anndata/core/anndata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit e102b98

Please sign in to comment.