diff --git a/apis/python/src/tiledbsoma/io/ingest.py b/apis/python/src/tiledbsoma/io/ingest.py index 230e3424e8..393dcaab1f 100644 --- a/apis/python/src/tiledbsoma/io/ingest.py +++ b/apis/python/src/tiledbsoma/io/ingest.py @@ -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. diff --git a/apis/python/testdata/xempty.h5ad b/apis/python/testdata/x-empty.h5ad similarity index 100% rename from apis/python/testdata/xempty.h5ad rename to apis/python/testdata/x-empty.h5ad diff --git a/apis/python/testdata/xnone.h5ad b/apis/python/testdata/x-none.h5ad similarity index 94% rename from apis/python/testdata/xnone.h5ad rename to apis/python/testdata/x-none.h5ad index 7405b60b3f..ba1569757e 100644 Binary files a/apis/python/testdata/xnone.h5ad and b/apis/python/testdata/x-none.h5ad differ diff --git a/apis/python/tests/test_basic_anndata_io.py b/apis/python/tests/test_basic_anndata_io.py index 4c1bd0b784..cb93d04cf7 100644 --- a/apis/python/tests/test_basic_anndata_io.py +++ b/apis/python/tests/test_basic_anndata_io.py @@ -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