Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-1.5] [python] Allow adata.X to be None #1772

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apis/python/src/tiledbsoma/io/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,10 @@ def from_anndata(
# chunkwise into memory.
# Using the latter allows us to ingest larger .h5ad files without OOMing.

# Some AnnData objects have no X at all.
has_X = True
# Some AnnData objects have no X at all. This might be a missing attribute
# anndata.X; it might be anndata.X present, but with value None.
try:
anndata.X
has_X = anndata.X is not None
except (NameError, KeyError):
# We need to check both -- different exception types occur dependinng
# on whether the anndata object is read in backing mode or not.
Expand Down
File renamed without changes.
Binary file not shown.
9 changes: 7 additions & 2 deletions apis/python/tests/test_basic_anndata_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,18 @@ def h5ad_file_categorical_int_nan(request):

@pytest.fixture
def h5ad_file_X_empty(request):
input_path = HERE.parent / "testdata/xempty.h5ad"
"""adata.X is a zero-cell sparse matrix"""
input_path = HERE.parent / "testdata/x-empty.h5ad"
return input_path


@pytest.fixture
def h5ad_file_X_none(request):
input_path = HERE.parent / "testdata/xnone.h5ad"
"""
adata.X has Python value None if read in non-backed mode; if read in backed
mode, adata.X is not present as an attribute of adata.
"""
input_path = HERE.parent / "testdata/x-none.h5ad"
return input_path


Expand Down
Loading