Skip to content

Commit

Permalink
Test for non-integer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
faymanns committed Dec 20, 2024
1 parent 1134be0 commit 1ae98fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion zarr/tests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os.path
import shutil
import warnings
import numbers

import numpy as np
import pytest
Expand Down Expand Up @@ -762,7 +763,13 @@ def test_create_with_storage_transformers(at_root):
)
def test_shape_chunk_ints(init_shape, init_chunks, shape, chunks):
g = open_group()
array = g.create_dataset("ds", shape=init_shape, chunks=init_chunks, dtype=np.uint8)
if not isinstance(init_shape[0], numbers.Integral) or not isinstance(
init_chunks[0], numbers.Integral
):
with pytest.warns(UserWarning):
array = g.create_dataset("ds", shape=init_shape, chunks=init_chunks, dtype=np.uint8)
else:
array = g.create_dataset("ds", shape=init_shape, chunks=init_chunks, dtype=np.uint8)

assert all(
isinstance(s, int) for s in array.shape
Expand Down
3 changes: 2 additions & 1 deletion zarr/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def test_normalize_shape():
with pytest.raises(TypeError):
normalize_shape(None)
with pytest.raises(ValueError):
normalize_shape("foo")
with pytest.warns(UserWarning):
normalize_shape("foo")


def test_normalize_chunks():
Expand Down

0 comments on commit 1ae98fd

Please sign in to comment.