Skip to content

Commit

Permalink
WIP expand test_sparse_string_domain for empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ihnorton committed Feb 8, 2022
1 parent 852673c commit e82a231
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tiledb/tests/test_libtiledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2701,7 +2701,16 @@ def test_sparse_mixed_domain_uint_float64(self, sparse_cell_order):
self.assertEqual(a_nonempty[0], (0, 49))
self.assertEqual(a_nonempty[1], (-100.0, 100.0))

def test_sparse_string_domain(self, sparse_cell_order):
@pytest.mark.parametrize(
"coords, expected_ned, allows_duplicates",
[
([b"aa", b"bbb", b"c", b"dddd"], [b"aa", b"dddd"], False),
([b"", b"", b"", b""], [b"", b""], True),
],
)
def test_sparse_string_domain(
self, coords, expected_ned, allows_duplicates, sparse_cell_order
):
path = self.path("sparse_string_domain")
dom = tiledb.Domain(tiledb.Dim(name="d", domain=(None, None), dtype=np.bytes_))
att = tiledb.Attr(name="a", dtype=np.int64)
Expand All @@ -2710,12 +2719,12 @@ def test_sparse_string_domain(self, sparse_cell_order):
attrs=(att,),
sparse=True,
cell_order=sparse_cell_order,
allows_duplicates=allows_duplicates,
capacity=10000,
)
tiledb.SparseArray.create(path, schema)

data = [1, 2, 3, 4]
coords = [b"aa", b"bbb", b"c", b"dddd"]

with tiledb.open(path, "w") as A:
A[coords] = data
Expand All @@ -2725,7 +2734,8 @@ def test_sparse_string_domain(self, sparse_cell_order):
res = A[ned[0] : ned[1]]
assert_array_equal(res["a"], data)
self.assertEqual(set(res["d"]), set(coords))
self.assertEqual(A.nonempty_domain(), ((b"aa", b"dddd"),))
# self.assertEqual(A.nonempty_domain(), ((b"aa", b"dddd"),))
self.assertEqual(A.nonempty_domain(), ((tuple(expected_ned)),))

def test_sparse_string_domain2(self, sparse_cell_order):
path = self.path("sparse_string_domain2")
Expand Down

0 comments on commit e82a231

Please sign in to comment.