Skip to content

Commit

Permalink
Fixed type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed May 25, 2018
1 parent 555c15c commit 8b1d56b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions anndata/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ class AnnData(IndexMixin, metaclass=utils.DeprecationMixinMeta):

def __init__(
self,
X: Optional[Union[np.ndarray, sparse.spmatrix]] = None,
X: Optional[Union[np.ndarray, sparse.spmatrix, ArrayView]] = None,
obs: Optional[Union[pd.DataFrame, Mapping[Any, Iterable[Any]], np.ndarray]] = None,
var: Optional[Union[pd.DataFrame, Mapping[Any, Iterable[Any]], np.ndarray]] = None,
uns: Optional[Mapping[Any, Any]] = None,
Expand Down Expand Up @@ -868,8 +868,8 @@ def shape(self):
return self.n_obs, self.n_vars

@property
def X(self) -> Union[np.ndarray, sparse.spmatrix, None]:
"""Data matrix of shape `n_obs` × `n_vars` (`np.ndarray`, `sp.sparse.spmatrix`) or `None`."""
def X(self) -> Optional[Union[np.ndarray, sparse.spmatrix, ArrayView]]:
"""Data matrix of shape `n_obs` × `n_vars`."""
if self.isbacked:
if not self.file.isopen: self.file.open()
X = self.file['X']
Expand Down
2 changes: 1 addition & 1 deletion anndata/readwrite/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def preprocess_writing(value):
and f[key].shape == value.shape \
and f[key].dtype == value.dtype \
and not isinstance(f[key], h5py.SparseDataset)
if not is_valid_group and not isinstance(value, sparse.spmatrix):
if not is_valid_group and not issparse(value):
f[key][()] = value
return
else:
Expand Down

0 comments on commit 8b1d56b

Please sign in to comment.