Skip to content

Commit

Permalink
[python] New-shape testing for tiledbsoma.io [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Oct 8, 2024
1 parent 29c16a7 commit c2e7a6c
Show file tree
Hide file tree
Showing 2 changed files with 292 additions and 150 deletions.
13 changes: 12 additions & 1 deletion apis/python/src/tiledbsoma/io/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
NotCreateableError,
SOMAError,
)
from .._flags import NEW_SHAPE_FEATURE_FLAG_ENABLED
from .._soma_array import SOMAArray
from .._soma_object import AnySOMAObject, SOMAObject
from .._tdb_handles import RawHandle
Expand Down Expand Up @@ -1203,9 +1204,13 @@ def _write_dataframe_impl(
arrow_table = _extract_new_values_for_append(df_uri, arrow_table, context)

try:
domain = None
if NEW_SHAPE_FEATURE_FLAG_ENABLED:
domain = ((0, int(df.shape[0]) - 1),)
soma_df = DataFrame.create(
df_uri,
schema=arrow_table.schema,
domain=domain,
platform_config=platform_config,
context=context,
)
Expand Down Expand Up @@ -1304,8 +1309,14 @@ def _create_from_matrix(
logging.log_io(None, f"START WRITING {uri}")

try:
shape: Sequence[Union[int, None]] = ()
# A SparseNDArray must be appendable in soma.io.
shape = [None for _ in matrix.shape] if cls.is_sparse else matrix.shape
if NEW_SHAPE_FEATURE_FLAG_ENABLED:
shape = tuple(int(e) for e in matrix.shape)
elif cls.is_sparse:
shape = tuple(None for _ in matrix.shape)
else:
shape = matrix.shape
soma_ndarray = cls.create(
uri,
type=pa.from_numpy_dtype(matrix.dtype),
Expand Down
Loading

0 comments on commit c2e7a6c

Please sign in to comment.