Skip to content

Commit

Permalink
add some sdf things, and n-d snda [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Jul 12, 2024
1 parent 558b8aa commit 95d5e5e
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 106 deletions.
26 changes: 26 additions & 0 deletions apis/python/src/tiledbsoma/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def create(
schema: pa.Schema,
index_column_names: Sequence[str] = (SOMA_JOINID,),
domain: Optional[Domain] = None,
# TODO: optional maxshape?
platform_config: Optional[options.PlatformConfig] = None,
context: Optional[SOMATileDBContext] = None,
tiledb_timestamp: Optional[OpenTimestamp] = None,
Expand Down Expand Up @@ -319,6 +320,31 @@ def count(self) -> int:
# if is it in read open mode, then it is a DataFrameWrapper
return cast(DataFrameWrapper, self._handle).count

@property
def shape(self) -> Tuple[int, ...]:
"""Returns capacity of each dimension, always a list of length ``ndim``.
This will not necessarily match the bounds of occupied cells within the array.
Rather, it is the bounds outside of which no data may be written.
Lifecycle:
Experimental.
"""
# XXX COMMENT ME
return cast(Tuple[int, ...], (self._handle.shape[0],))

@property
def maxshape(self) -> Tuple[int, ...]:
"""XXX write me please thank you
Lifecycle:
Experimental.
"""
# XXX COMMENT ME
return cast(Tuple[int, ...], (self._handle.maxshape[0],))

def resize(self, newshape: Sequence[Union[int, None]]):
"""Comment me please thx"""
self._handle.resize(newshape)

def __len__(self) -> int:
"""Returns the number of rows in the dataframe. Same as ``df.count``."""
return self.count
Expand Down
8 changes: 6 additions & 2 deletions apis/python/src/tiledbsoma/_dense_nd_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ def maxshape(self) -> Tuple[int, ...]:
# For core 2.26 we'll implement this for sparse and dense.
# For core 2.25 we'll implement this only for dense.
# This suppression overrides the parent class.
raise NotImplementedError("DenseNDArray maxshape support is scheduled for TileDBSOMA 1.14")
raise NotImplementedError(
"DenseNDArray maxshape support is scheduled for TileDBSOMA 1.14"
)

def resize(self, newshape: Sequence[Union[int, None]]):
"""XXX write me please thank you
Expand All @@ -334,4 +336,6 @@ def resize(self, newshape: Sequence[Union[int, None]]):
# For core 2.26 we'll implement this for sparse and dense.
# For core 2.25 we'll implement this only for dense.
# This suppression overrides the parent class.
raise NotImplementedError("DenseNDArray resize support is scheduled for TileDBSOMA 1.14")
raise NotImplementedError(
"DenseNDArray resize support is scheduled for TileDBSOMA 1.14"
)
6 changes: 2 additions & 4 deletions apis/python/src/tiledbsoma/_tdb_handles.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,11 @@ def write(self, values: pa.RecordBatch) -> None:

@property
def shape(self) -> Tuple[int, ...]:
# Shape is not implemented for DataFrames
raise NotImplementedError
return tuple(self._handle.shape)

@property
def maxshape(self) -> Tuple[int, ...]:
# Shape is not implemented for DataFrames -- XXX ?!?
raise NotImplementedError
return tuple(self._handle.maxshape)


class DenseNDArrayWrapper(SOMAArrayWrapper[clib.SOMADenseNDArray]):
Expand Down
Loading

0 comments on commit 95d5e5e

Please sign in to comment.