Skip to content

Commit

Permalink
[python] Fix from_anndata() to respect var_id_name (#1963) (#1964)
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron Wolen <aaron@wolen.com>
  • Loading branch information
github-actions[bot] and aaronwolen committed Dec 6, 2023
1 parent b3e802d commit 50f6eae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apis/python/src/tiledbsoma/io/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def from_anndata(
with _write_dataframe(
_util.uri_joinpath(measurement_uri, "var"),
conversions.decategoricalize_obs_or_var(anndata.var),
id_column_name="var_id",
id_column_name=var_id_name,
platform_config=platform_config,
context=context,
ingestion_params=ingestion_params,
Expand Down
12 changes: 12 additions & 0 deletions apis/python/tests/test_basic_anndata_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,18 @@ def test_id_names(tmp_path, obs_id_name, var_id_name, indexify_obs, indexify_var
assert obs_id_name in exp.obs.keys()
assert var_id_name in exp.ms["RNA"].var.keys()

if indexify_obs:
expected_obs_keys = ["soma_joinid", obs_id_name] + adata.obs_keys()
else:
expected_obs_keys = ["soma_joinid"] + adata.obs_keys()
assert list(exp.obs.keys()) == expected_obs_keys

if indexify_var:
expected_var_keys = ["soma_joinid", var_id_name] + adata.var_keys()
else:
expected_var_keys = ["soma_joinid"] + adata.var_keys()
assert list(exp.ms["RNA"].var.keys()) == expected_var_keys

# Implicitly, a check for no-throw
bdata = tiledbsoma.io.to_anndata(
exp,
Expand Down

0 comments on commit 50f6eae

Please sign in to comment.