Skip to content

Commit aa986d4

Browse files
authored
Skip datetime, timedelta, and complex with N5Store (#411)
The N5 spec does not currently list support for datetime, timedelta, and complex typed data. So customize `test_dtype` for `N5Store` to avoid these and instead focus on the types `N5Store` does support.
1 parent e20afc2 commit aa986d4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

zarr/tests/test_core.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,30 @@ def test_structured_array_nested(self):
15571557
with pytest.raises(TypeError):
15581558
self.check_structured_array(d, fill_values)
15591559

1560+
def test_dtypes(self):
1561+
1562+
# integers
1563+
for dtype in 'u1', 'u2', 'u4', 'u8', 'i1', 'i2', 'i4', 'i8':
1564+
z = self.create_array(shape=10, chunks=3, dtype=dtype)
1565+
assert z.dtype == np.dtype(dtype)
1566+
a = np.arange(z.shape[0], dtype=dtype)
1567+
z[:] = a
1568+
assert_array_equal(a, z[:])
1569+
1570+
# floats
1571+
for dtype in 'f2', 'f4', 'f8':
1572+
z = self.create_array(shape=10, chunks=3, dtype=dtype)
1573+
assert z.dtype == np.dtype(dtype)
1574+
a = np.linspace(0, 1, z.shape[0], dtype=dtype)
1575+
z[:] = a
1576+
assert_array_almost_equal(a, z[:])
1577+
1578+
# check that datetime generic units are not allowed
1579+
with pytest.raises(ValueError):
1580+
self.create_array(shape=100, dtype='M8')
1581+
with pytest.raises(ValueError):
1582+
self.create_array(shape=100, dtype='m8')
1583+
15601584
def test_object_arrays(self):
15611585

15621586
# an object_codec is required for object arrays

0 commit comments

Comments
 (0)