Skip to content

Commit 62f61c5

Browse files
committed
Add tests
1 parent 8f70ac0 commit 62f61c5

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

tiledb/tests/test_query_condition.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,11 +694,26 @@ def test_deprecate_attr_cond(self):
694694

695695
def test_on_dense_dimensions(self):
696696
with tiledb.open(self.create_input_array_UIDSA(sparse=False)) as A:
697-
with pytest.raises(tiledb.TileDBError) as excinfo:
698-
A.query(cond="2 <= d < 6")[:]
699-
assert (
700-
"Cannot apply query condition to dimensions on dense arrays"
701-
) in str(excinfo.value)
697+
result = A.query(cond="2 <= d < 6")[:]
698+
expected = A[2:6]
699+
assert_array_equal(result["U"][1:5], expected["U"])
700+
701+
# Cells outside the condition should be filled with fill values
702+
assert result["U"][0] == np.iinfo(np.uint32).max
703+
704+
def test_on_dense_dimensions_combined_with_attrs(self):
705+
with tiledb.open(self.create_input_array_UIDSA(sparse=False)) as A:
706+
result = A.query(cond="2 <= d < 6 and U > 3")[:]
707+
full = A[:]
708+
709+
# Build a mask matching the query condition "2 <= d < 6 and U > 3"
710+
d = np.arange(1, 11, dtype=np.uint32)
711+
match = (d >= 2) & (d < 6) & (full["U"] > 3)
712+
fill = np.iinfo(np.uint32).max
713+
714+
# Matching cells keep their values, non-matching cells get fill
715+
assert_array_equal(result["U"][match], full["U"][match])
716+
assert_array_equal(result["U"][~match], fill)
702717

703718
def test_on_sparse_dimensions(self):
704719
with tiledb.open(self.create_input_array_UIDSA(sparse=True)) as A:

0 commit comments

Comments
 (0)