Skip to content

Commit 19499b2

Browse files
authored
Revert "Dense Array [:] Returns Nonempty Domain Only (#1199)" (#1261)
- This reverts commit f7145ed - The regular indexer should return the entire array, not just the nonempty domain, to maintain NumPy semantics
1 parent 9938cf8 commit 19499b2

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
## API Changes
88
* Addition of `in` operator for `QueryCondition` [#1214](https://github.com/TileDB-Inc/TileDB-Py/pull/1214)
9+
* Revert the regular indexer `[:]` to return entire array rather than nonempty domain in order to maintain NumPy semantics [#1261](https://github.com/TileDB-Inc/TileDB-Py/pull/1261)
910

1011
## Bug Fixes
1112
* Deprecate `Filestore.import_uri` in lieu of `Filestore.copy_from` [#1226](https://github.com/TileDB-Inc/TileDB-Py/pull/1226)

tiledb/libtiledb.pyx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ def replace_scalars_slice(dom: Domain, idx: tuple):
25622562
return tuple(new_idx), tuple(drop_axes)
25632563

25642564

2565-
def index_domain_subarray(array: Array, dom: Domain, idx: tuple, read_array: bool = False):
2565+
def index_domain_subarray(array: Array, dom: Domain, idx: tuple):
25662566
"""
25672567
Return a numpy array representation of the tiledb subarray buffer
25682568
for a given domain and tuple of index slices
@@ -2580,17 +2580,9 @@ def index_domain_subarray(array: Array, dom: Domain, idx: tuple, read_array: boo
25802580

25812581
if np.issubdtype(dim_dtype, np.unicode_) or np.issubdtype(dim_dtype, np.bytes_):
25822582
ned = array.nonempty_domain()
2583-
(dim_lb, dim_ub) = ned[r] if ned is not None else (None, None)
2583+
(dim_lb, dim_ub) = ned[r] if ned else (None, None)
25842584
else:
2585-
if read_array:
2586-
ned = array.nonempty_domain()
2587-
(dim_lb, dim_ub) = (
2588-
np.array(ned[r], dim_dtype)
2589-
if ned is not None
2590-
else dim.domain
2591-
)
2592-
else:
2593-
(dim_lb, dim_ub) = dim.domain
2585+
(dim_lb, dim_ub) = dim.domain
25942586

25952587

25962588
dim_slice = idx[r]
@@ -4502,7 +4494,7 @@ cdef class DenseArrayImpl(Array):
45024494
selection = index_as_tuple(selection)
45034495
idx = replace_ellipsis(self.schema.domain.ndim, selection)
45044496
idx, drop_axes = replace_scalars_slice(self.schema.domain, idx)
4505-
subarray = index_domain_subarray(self, self.schema.domain, idx, True)
4497+
subarray = index_domain_subarray(self, self.schema.domain, idx)
45064498
# Note: we included dims (coords) above to match existing semantics
45074499
out = self._read_dense_subarray(subarray, attr_names, attr_cond, layout,
45084500
coords)

tiledb/tests/test_libtiledb.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,21 +1816,6 @@ def test_reopen_dense_array(self):
18161816

18171817
T.close()
18181818

1819-
def test_writing_partial_dense_array(self):
1820-
uri = self.path("test_writing_partial_dense_array")
1821-
1822-
dom = tiledb.Domain(tiledb.Dim(domain=(0, 1000), tile=1000, dtype=np.int64))
1823-
attr = tiledb.Attr(name="rows", dtype=np.int64)
1824-
schema = tiledb.ArraySchema(domain=dom, sparse=False, attrs=[attr])
1825-
tiledb.Array.create(uri, schema)
1826-
1827-
with tiledb.open(uri, "w") as A:
1828-
A[0:1000] = np.arange(1000)
1829-
1830-
with tiledb.open(uri) as A:
1831-
ned = A.nonempty_domain()[0]
1832-
assert len(A[:]["rows"]) == ned[1] - ned[0] + 1
1833-
18341819

18351820
class TestVarlen(DiskTestCase):
18361821
def test_varlen_write_bytes(self):

0 commit comments

Comments
 (0)