Skip to content

Commit

Permalink
Addition of test_from_numpy_empty_str Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenv committed Jul 5, 2022
1 parent ff22b8a commit 3f1b5f8
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tiledb/tests/test_libtiledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1834,13 +1834,7 @@ def test_varlen_write_bytes(self):
assert_array_equal(A, T.multi_index[1 : len(A)][""])

def test_varlen_sparse_all_empty_strings(self):
# this test addresses a fix for specific need for reads on a
# large existing array, see
# https://github.com/TileDB-Inc/TileDB-Py/pull/475
# we currently have to write a placeholder at the end to
# avoid zero-length cell error
# TODO: follow-up with improved testing for empty var-length/strings
A = np.array(["", "", "", "", "", "\x00"], dtype=object)
A = np.array(["", "", "", "", ""], dtype=object)
dim_len = len(A)
uri = self.path("varlen_all_empty_strings")

Expand Down Expand Up @@ -3535,6 +3529,19 @@ def test_from_numpy_timestamp(self):
with tiledb.open(path, timestamp=(10, 10)) as A:
assert A.nonempty_domain() == ((0, 2),)

@pytest.mark.parametrize("empty_str", ["", b""])
@pytest.mark.parametrize("num_strs", [1, 1000])
def test_from_numpy_empty_str(self, empty_str, num_strs):
uri = self.path("test_from_numpy_empty_str")
np_array = np.asarray([empty_str] * num_strs, dtype="O")
tiledb.from_numpy(uri, np_array)

with tiledb.open(uri, "r") as A:
assert_array_equal(A[:], np_array)
if has_pandas():
assert_array_equal(A.query(use_arrow=True).df[:][""], np_array)
assert_array_equal(A.query(use_arrow=False).df[:][""], np_array)


class ConsolidationTest(DiskTestCase):
def test_array_vacuum(self):
Expand Down

0 comments on commit 3f1b5f8

Please sign in to comment.