Skip to content

Commit

Permalink
[python] Expand unit-testing for enumerated types
Browse files Browse the repository at this point in the history
  • Loading branch information
John Kerl committed Aug 18, 2023
1 parent ef4d7b7 commit e0846eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apis/python/devtools/outgestor
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def main():
"--var-id-name",
help="Which var column name to use as index for outgested andata",
type=str,
default="obs_id",
default="var_id",
)
parser.add_argument(
"paths",
Expand Down
16 changes: 16 additions & 0 deletions apis/python/tests/test_basic_anndata_io.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
import pathlib
import tempfile
from pathlib import Path
Expand Down Expand Up @@ -476,3 +477,18 @@ def test_null_obs(adata, tmp_path: Path):
# of the Pandas data frame
for k in adata.obs:
assert obs.attr(k).isnullable == adata.obs[k].isnull().any()


# There exist in the wild AnnData files with categorical-int columns where the "not in the category"
# is indicated by the presence of floating-point math.NaN in cells. Here we test that we can ingest
# this.
def test_obs_with_categorical_int_nan_enumeration(tmp_path, adata):
output_path = tmp_path.as_uri()

# Currently getting float not int here, failing to repro the problem
s = pd.Series(list(range(len(adata.obs))))
s[0] = math.nan
adata.obs["categ_int_nan"] = s

output_path = tmp_path.as_posix()
tiledbsoma.io.from_anndata(output_path, adata, measurement_name="RNA")

0 comments on commit e0846eb

Please sign in to comment.