Skip to content

Commit b3a1b37

Browse files
adapted to anndata not exporting anndata.base anymore
Adapting according to discussion at scverse/anndata#174.
1 parent 46ea81f commit b3a1b37

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

batchglm/data.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
except ImportError:
2121
anndata = None
2222

23+
try:
24+
from anndata.base import Raw
25+
except ImportError:
26+
from anndata import Raw
27+
2328

2429
def _sparse_to_xarray(data, dims):
2530
num_observations, num_features = data.shape
@@ -54,7 +59,7 @@ def fetch_X(idx):
5459

5560

5661
def xarray_from_data(
57-
data: Union[anndata.AnnData, anndata.base.Raw, xr.DataArray, xr.Dataset, np.ndarray, scipy.sparse.csr_matrix],
62+
data: Union[anndata.AnnData, Raw, xr.DataArray, xr.Dataset, np.ndarray, scipy.sparse.csr_matrix],
5863
dims: Union[Tuple, List] = ("observations", "features")
5964
):
6065
"""
@@ -65,7 +70,7 @@ def xarray_from_data(
6570
:param dims: tuple or list with two strings. Specifies the names of the xarray dimensions.
6671
:return: xr.DataArray of shape `dims`
6772
"""
68-
if anndata is not None and (isinstance(data, anndata.AnnData) or isinstance(data, anndata.base.Raw)):
73+
if anndata is not None and (isinstance(data, anndata.AnnData) or isinstance(data, Raw)):
6974
# Anndata.raw does not have obs_names.
7075
if isinstance(data, anndata.AnnData):
7176
obs_names = np.asarray(data.obs_names)

0 commit comments

Comments
 (0)