From 2c8fa2914c878e5ba34ae0f898eebec2c6de20e4 Mon Sep 17 00:00:00 2001 From: Vivian Nguyen Date: Fri, 20 Oct 2023 16:31:38 -0500 Subject: [PATCH] Post-rebase corrections --- apis/python/src/tiledbsoma/_sparse_nd_array.py | 2 +- apis/python/src/tiledbsoma/_tdb_handles.py | 17 +++++++---------- apis/python/src/tiledbsoma/_tiledb_array.py | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/apis/python/src/tiledbsoma/_sparse_nd_array.py b/apis/python/src/tiledbsoma/_sparse_nd_array.py index 72bf99b868..d493cabf2c 100644 --- a/apis/python/src/tiledbsoma/_sparse_nd_array.py +++ b/apis/python/src/tiledbsoma/_sparse_nd_array.py @@ -345,7 +345,7 @@ def used_shape(self) -> Tuple[Tuple[int, int], ...]: # In the unlikely event that a previous data update succeeded but the # subsequent metadata update did not, take the union of the core non-empty domain # (which is done as part of the data update) and the metadata bounding box. - ned = self.non_empty_domain() + ned = self.non_empty_domain() or tuple() for i, nedslot in enumerate(ned): ned_lower, ned_upper = nedslot bbox_lower, bbox_upper = retval[i] diff --git a/apis/python/src/tiledbsoma/_tdb_handles.py b/apis/python/src/tiledbsoma/_tdb_handles.py index 0ef17cc8a0..9b5b1ac80c 100644 --- a/apis/python/src/tiledbsoma/_tdb_handles.py +++ b/apis/python/src/tiledbsoma/_tdb_handles.py @@ -200,16 +200,12 @@ def _opener( def schema(self) -> tiledb.ArraySchema: return self._handle.schema - def non_empty_domain(self) -> Tuple[Tuple[int, int], ...]: - """ - Retrieves the non-empty domain for each dimension, namely the smallest - and largest indices in each dimension for which the array/dataframe has - data occupied. This is nominally the same as the domain used at - creation time, but if for example only a portion of the available domain - has actually had data written, this function will return a tighter - range. - """ - return self._handle.nonempty_domain() # type: ignore + def non_empty_domain(self) -> Optional[Tuple[Tuple[Any, Any], ...]]: + try: + ned: Optional[Tuple[Tuple[Any, Any], ...]] = self._handle.nonempty_domain() + return ned + except tiledb.TileDBError as e: + raise SOMAError(e) @property def domain(self) -> Tuple[Tuple[Any, Any], ...]: @@ -230,6 +226,7 @@ def dim_names(self) -> Tuple[str, ...]: schema = self._handle.schema return tuple(schema.domain.dim(i).name for i in range(schema.domain.ndim)) + @attrs.define(frozen=True) class GroupEntry: uri: str diff --git a/apis/python/src/tiledbsoma/_tiledb_array.py b/apis/python/src/tiledbsoma/_tiledb_array.py index cffb2a40b4..6f405b5b6a 100644 --- a/apis/python/src/tiledbsoma/_tiledb_array.py +++ b/apis/python/src/tiledbsoma/_tiledb_array.py @@ -70,7 +70,7 @@ def schema(self) -> pa.Schema: else: return self._tiledb_array_schema() - def non_empty_domain(self) -> Tuple[Tuple[int, int], ...]: + def non_empty_domain(self) -> Optional[Tuple[Tuple[Any, Any], ...]]: """ Retrieves the non-empty domain for each dimension, namely the smallest and largest indices in each dimension for which the array/dataframe has