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

[python] Use new shape in one more spot #3321

Merged
merged 2 commits into from
Nov 13, 2024
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
13 changes: 8 additions & 5 deletions apis/python/src/tiledbsoma/io/outgest.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,14 @@
num_cols = width_configs.get(element_name, None)

if num_cols is None:
try:
used_shape = soma_nd_array.used_shape()
num_cols = used_shape[1][1] + 1
except SOMAError:
pass # We tried; moving on to next option
if soma_nd_array.tiledbsoma_has_upgraded_shape:
num_cols = soma_nd_array.shape[1]
else:
try:
used_shape = soma_nd_array.used_shape()
num_cols = used_shape[1][1] + 1
except SOMAError:
pass # We tried; moving on to next option

Check warning on line 453 in apis/python/src/tiledbsoma/io/outgest.py

View check run for this annotation

Codecov / codecov/patch

apis/python/src/tiledbsoma/io/outgest.py#L449-L453

Added lines #L449 - L453 were not covered by tests

if num_cols is None:
num_rows_times_width, coo_column_count = matrix_tbl.shape
Expand Down
10 changes: 5 additions & 5 deletions apis/python/tests/test_basic_anndata_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,14 +822,14 @@ def test_export_obsm_with_holes(h5ad_file_with_obsm_holes, tmp_path):
meta["soma_dim_1_domain_upper"]
assert meta["soma_object_type"] == "SOMASparseNDArray"

# Now try the remaining options for outgest.
with pytest.raises(tiledbsoma.SOMAError):
tiledbsoma.io.to_anndata(exp, "RNA")
# No longer throws as of new-shape feature in TileDB-SOMA 1.15.
try3 = tiledbsoma.io.to_anndata(exp, "RNA")
assert try3.obsm["X_pca"].shape == (2638, 50)

try3 = tiledbsoma.io.to_anndata(
try4 = tiledbsoma.io.to_anndata(
exp, "RNA", obsm_varm_width_hints={"obsm": {"X_pca": 50}}
)
assert try3.obsm["X_pca"].shape == (2638, 50)
assert try4.obsm["X_pca"].shape == (2638, 50)


def test_X_empty(h5ad_file_X_empty):
Expand Down
Loading