Skip to content

Commit 235e246

Browse files
committed
mypy fixes
1 parent 77f40a5 commit 235e246

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/zarr/core/array.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3786,7 +3786,9 @@ def _parse_chunk_encoding_v2(
37863786
if filters == "auto":
37873787
_filters = default_filters
37883788
else:
3789-
if not all(isinstance(f, numcodecs.abc.Codec) for f in filters):
3789+
if isinstance(filters, Iterable) and not all(
3790+
isinstance(f, numcodecs.abc.Codec) for f in filters
3791+
):
37903792
raise TypeError(
37913793
"For Zarr v2 arrays, all elements of `filters` must be numcodecs codecs."
37923794
)

src/zarr/testing/strategies.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from zarr.core.array import Array
1111
from zarr.core.sync import sync
1212
from zarr.storage import MemoryStore, StoreLike
13+
from zarr.storage.common import _dereference_path
1314

1415
# Copied from Xarray
1516
_attr_keys = st.text(st.characters(), min_size=1)
@@ -137,7 +138,7 @@ def arrays(
137138

138139
expected_attrs = {} if attributes is None else attributes
139140

140-
array_path = path + ("/" if not path.endswith("/") else "") + name
141+
array_path = _dereference_path(path, name)
141142
root = zarr.open_group(store, mode="w", zarr_format=zarr_format)
142143

143144
a = root.create_array(

tests/test_group.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,20 +614,24 @@ def test_group_create_array(
614614
data = np.arange(np.prod(shape)).reshape(shape).astype(dtype)
615615

616616
if method == "create_array":
617-
array = group.create_array(name="array", shape=shape, dtype=dtype, data=data)
617+
array = group.create_array(name="array", shape=shape, dtype=dtype)
618+
array[:] = data
618619
elif method == "array":
619620
with pytest.warns(DeprecationWarning):
620-
array = group.array(name="array", shape=shape, dtype=dtype, data=data)
621+
array = group.array(name="array", shape=shape, dtype=dtype)
622+
array[:] = data
621623
else:
622624
raise AssertionError
623625

624626
if not overwrite:
625627
if method == "create_array":
626628
with pytest.raises(ContainsArrayError):
627-
group.create_array(name="array", shape=shape, dtype=dtype, data=data)
629+
a = group.create_array(name="array", shape=shape, dtype=dtype)
630+
a[:] = data
628631
elif method == "array":
629632
with pytest.raises(ContainsArrayError), pytest.warns(DeprecationWarning):
630-
group.array(name="array", shape=shape, dtype=dtype, data=data)
633+
a = group.array(name="array", shape=shape, dtype=dtype)
634+
a[:] = data
631635
assert array.shape == shape
632636
assert array.dtype == np.dtype(dtype)
633637
assert np.array_equal(array[:], data)

0 commit comments

Comments
 (0)