Skip to content

Commit f272f88

Browse files
committed
extra object tests
1 parent f380374 commit f272f88

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

zarr/tests/test_core.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,16 @@ def test_object_arrays_vlen_text(self):
948948
data = np.array(greetings * 1000, dtype=object)
949949

950950
z = self.create_array(shape=data.shape, dtype=object, object_codec=VLenUTF8())
951+
z[0] = u'foo'
952+
assert z[0] == u'foo'
953+
z[1] = u'bar'
954+
assert z[1] == u'bar'
955+
z[2] = u'baz'
956+
assert z[2] == u'baz'
951957
z[:] = data
952-
assert_array_equal(data, z[:])
958+
a = z[:]
959+
assert a.dtype == object
960+
assert_array_equal(data, a)
953961

954962
# convenience API
955963
z = self.create_array(shape=data.shape, dtype=text_type)
@@ -981,8 +989,16 @@ def test_object_arrays_vlen_bytes(self):
981989
data = np.array(greetings_bytes * 1000, dtype=object)
982990

983991
z = self.create_array(shape=data.shape, dtype=object, object_codec=VLenBytes())
992+
z[0] = b'foo'
993+
assert z[0] == b'foo'
994+
z[1] = b'bar'
995+
assert z[1] == b'bar'
996+
z[2] = b'baz'
997+
assert z[2] == b'baz'
984998
z[:] = data
985-
assert_array_equal(data, z[:])
999+
a = z[:]
1000+
assert a.dtype == object
1001+
assert_array_equal(data, a)
9861002

9871003
# convenience API
9881004
z = self.create_array(shape=data.shape, dtype=binary_type)
@@ -1013,8 +1029,12 @@ def compare_arrays(expected, actual, item_dtype):
10131029
codecs = VLenArray(int), VLenArray('<u4')
10141030
for codec in codecs:
10151031
z = self.create_array(shape=data.shape, dtype=object, object_codec=codec)
1032+
z[0] = np.array([4, 7])
1033+
assert_array_equal(np.array([4, 7]), z[0])
10161034
z[:] = data
1017-
compare_arrays(data, z[:], codec.dtype)
1035+
a = z[:]
1036+
assert a.dtype == object
1037+
compare_arrays(data, a, codec.dtype)
10181038

10191039
# convenience API
10201040
for item_type in 'int', '<u4':

0 commit comments

Comments
 (0)