Skip to content

Commit

Permalink
[python] Experiment-level shaping [WIP] [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Oct 9, 2024
1 parent 50d63c1 commit 8938131
Show file tree
Hide file tree
Showing 5 changed files with 503 additions and 3 deletions.
10 changes: 8 additions & 2 deletions apis/python/src/tiledbsoma/_sparse_nd_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,18 @@ def resize(
self._handle.resize(newshape)
return (True, "")

def tiledbsoma_upgrade_shape(self, newshape: Sequence[Union[int, None]]) -> None:
def tiledbsoma_upgrade_shape(
self, newshape: Sequence[Union[int, None]], check_only: bool = False
) -> StatusAndReason:
"""Allows the array to have a resizeable shape as described in the TileDB-SOMA
1.15 release notes. Raises an error if the new shape exceeds maxshape in
any dimension. Raises an error if the array already has a shape.
"""
self._handle.tiledbsoma_upgrade_shape(newshape)
if check_only:
return self._handle.tiledbsoma_can_upgrade_shape(newshape)
else:
self._handle.tiledbsoma_upgrade_shape(newshape)
return (True, "")

def write(
self,
Expand Down
17 changes: 17 additions & 0 deletions apis/python/src/tiledbsoma/_tdb_handles.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ def tiledbsoma_upgrade_shape(self, newshape: Sequence[Union[int, None]]) -> None
"""Not implemented for DataFrame."""
raise NotImplementedError

def tiledbsoma_can_upgrade_shape(
self, newshape: Sequence[Union[int, None]]
) -> StatusAndReason:
"""Not implemented for DataFrame."""
raise NotImplementedError

def resize_soma_joinid_shape(self, newshape: int) -> None:
"""Only implemented for DataFrame."""
raise NotImplementedError
Expand Down Expand Up @@ -672,6 +678,17 @@ def tiledbsoma_upgrade_shape(self, newshape: Sequence[Union[int, None]]) -> None
"""
self._handle.tiledbsoma_upgrade_shape(newshape)

def tiledbsoma_can_upgrade_shape(
self, newshape: Sequence[Union[int, None]]
) -> StatusAndReason:
"""Allows the array to have a resizeable shape as described in the TileDB-SOMA
1.15 release notes. Raises an error if the new shape exceeds maxshape in
any dimension. Raises an error if the array already has a shape.
"""
return cast(
StatusAndReason, self._handle.tiledbsoma_can_upgrade_shape(newshape)
)


class _DictMod(enum.Enum):
"""State machine to keep track of modifications to a dictionary.
Expand Down
8 changes: 8 additions & 0 deletions apis/python/src/tiledbsoma/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
to_anndata,
to_h5ad,
)
from .shaping import (
resize_experiment,
show_experiment_shapes,
upgrade_experiment_shapes,
)

__all__ = (
"add_matrix_to_collection",
Expand All @@ -37,5 +42,8 @@
"update_matrix",
"update_obs",
"update_var",
"upgrade_experiment_shapes",
"show_experiment_shapes",
"resize_experiment",
"ExperimentAmbientLabelMapping",
)
Loading

0 comments on commit 8938131

Please sign in to comment.