Skip to content

Commit 41b653e

Browse files
committed
Make assertion generic
1 parent 806d1ae commit 41b653e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tiledb/tests/test_schema_evolution.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ def test_schema_evolution_extend_check_bad_type():
234234
reason="Dropping a fixed-sized attribute and adding it back"
235235
"as a var-sized attribute is not supported in TileDB < 2.27",
236236
)
237-
def test_schema_evolution_drop_fixed_attribute_and_add_back_as_var_sized(tmp_path):
237+
@pytest.mark.parametrize("dtype_str", ["S", "U"])
238+
def test_schema_evolution_drop_fixed_attribute_and_add_back_as_var_sized(
239+
tmp_path, dtype_str
240+
):
238241
ctx = tiledb.default_ctx()
239242
uri = str(tmp_path)
240243
attrs = [
@@ -260,21 +263,23 @@ def test_schema_evolution_drop_fixed_attribute_and_add_back_as_var_sized(tmp_pat
260263
assert A.schema.attr("b").dtype == np.int32
261264

262265
se = tiledb.ArraySchemaEvolution(ctx)
263-
newattr = tiledb.Attr("a", dtype="S", var=True)
266+
newattr = tiledb.Attr("a", dtype=dtype_str, var=True)
264267
se.add_attribute(newattr)
265268
se.array_evolve(uri)
266269

267270
# check schema and data after adding attribute back as a var-sized attribute
268271
with tiledb.open(uri) as A:
269272
assert A.schema.has_attr("a")
270-
assert A.schema.attr("a").dtype == "S"
273+
assert A.schema.attr("a").dtype == dtype_str
271274
assert A.schema.attr("b").dtype == np.int32
272-
# check that each value == b'\x80' (empty byte)
273-
assert_array_equal(A[:]["a"], np.array([b"\x80" for _ in range(10)]))
275+
# check that each value equals to the fill value of "a" attribute
276+
assert_array_equal(A[:]["a"], np.array([newattr.fill] * 10, dtype=dtype_str))
277+
# check that nothing has changed for the "b" attribute
278+
assert_array_equal(A[:]["b"], original_data)
274279

275280
# add new data to the array
276281
new_data = np.array(
277-
["tiledb-string-n.{}".format(i) for i in range(1, 11)], dtype="S"
282+
["tiledb-string-n.{}".format(i) for i in range(1, 11)], dtype=dtype_str
278283
)
279284
with tiledb.open(uri, "w") as A:
280285
A[:] = {"a": new_data, "b": original_data}

0 commit comments

Comments
 (0)