Skip to content

Commit 1ae98fd

Browse files
committed
Test for non-integer warnings
1 parent 1134be0 commit 1ae98fd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

zarr/tests/test_creation.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os.path
33
import shutil
44
import warnings
5+
import numbers
56

67
import numpy as np
78
import pytest
@@ -762,7 +763,13 @@ def test_create_with_storage_transformers(at_root):
762763
)
763764
def test_shape_chunk_ints(init_shape, init_chunks, shape, chunks):
764765
g = open_group()
765-
array = g.create_dataset("ds", shape=init_shape, chunks=init_chunks, dtype=np.uint8)
766+
if not isinstance(init_shape[0], numbers.Integral) or not isinstance(
767+
init_chunks[0], numbers.Integral
768+
):
769+
with pytest.warns(UserWarning):
770+
array = g.create_dataset("ds", shape=init_shape, chunks=init_chunks, dtype=np.uint8)
771+
else:
772+
array = g.create_dataset("ds", shape=init_shape, chunks=init_chunks, dtype=np.uint8)
766773

767774
assert all(
768775
isinstance(s, int) for s in array.shape

zarr/tests/test_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def test_normalize_shape():
4444
with pytest.raises(TypeError):
4545
normalize_shape(None)
4646
with pytest.raises(ValueError):
47-
normalize_shape("foo")
47+
with pytest.warns(UserWarning):
48+
normalize_shape("foo")
4849

4950

5051
def test_normalize_chunks():

0 commit comments

Comments
 (0)