Skip to content

Commit

Permalink
attempt to work around anndata 0.10.0 [WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Oct 9, 2023
1 parent e55dcd3 commit bffe837
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions apis/python/src/tiledbsoma/io/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@
import scipy.sparse as sp
import tiledb
from anndata._core import file_backing
from anndata._core.sparse_dataset import SparseDataset
from packaging import version

# * When the user provides AnnData in non-backed mode, e.g. adata =
# ad.read_h5ad('foo.h5ad'), we have matrices like scipy.csr_matrix.
# * When the user provides AnnData in backed mode, e.g. adata =
# ad.read_h5ad('foo.h5ad', 'r'), we have matrices like SparseDataset.
# * AnnData 0.10.0 split SparseDataset into CSCDataSet and CSRDataSet.
if version.parse(ad.__version__) < version.parse("0.10.0"):
from anndata._core.sparse_dataset import SparseDataset
else:
from anndata._core.sparse_dataset import CSCDataSet, CSRDataSet

from somacore.options import PlatformConfig

from .. import (
Expand Down Expand Up @@ -73,7 +84,10 @@
signatures,
)

SparseMatrix = Union[sp.csr_matrix, sp.csc_matrix, SparseDataset]
if version.parse(ad.__version__) < version.parse("0.10.0"):
SparseMatrix = Union[sp.csr_matrix, sp.csc_matrix, SparseDataset]
else:
SparseMatrix = Union[sp.csr_matrix, sp.csc_matrix, CSCDataSet, CSRDataSet]
DenseMatrix = Union[NPNDArray, h5py.Dataset]
Matrix = Union[DenseMatrix, SparseMatrix]
_NDArr = TypeVar("_NDArr", bound=NDArray)
Expand Down

0 comments on commit bffe837

Please sign in to comment.