Skip to content

Commit 363f06b

Browse files
committed
fix mypy in test_array.py
1 parent 3835768 commit 363f06b

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/zarr/api/synchronous.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import zarr.core.array
99
from zarr._compat import _deprecate_positional_args
1010
from zarr.core.array import Array, AsyncArray
11-
from zarr.core.buffer.core import NDArrayLike
1211
from zarr.core.group import Group
1312
from zarr.core.sync import sync
1413

@@ -28,6 +27,7 @@
2827
)
2928
from zarr.core.array_spec import ArrayConfig, ArrayConfigLike
3029
from zarr.core.buffer import NDArrayOrScalarLike
30+
from zarr.core.buffer.core import NDArrayLike
3131
from zarr.core.chunk_key_encodings import ChunkKeyEncoding, ChunkKeyEncodingLike
3232
from zarr.core.common import (
3333
JSON,

tests/test_array.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
create_array,
3939
)
4040
from zarr.core.buffer import default_buffer_prototype
41+
from zarr.core.buffer.core import NDArrayLike
4142
from zarr.core.buffer.cpu import NDBuffer
4243
from zarr.core.chunk_grids import _auto_partition
4344
from zarr.core.common import JSON, MemoryOrder, ZarrFormat
@@ -654,35 +655,43 @@ def test_resize_1d(store: MemoryStore, zarr_format: ZarrFormat) -> None:
654655
)
655656
a = np.arange(105, dtype="i4")
656657
z[:] = a
658+
result = z[:]
659+
assert isinstance(result, NDArrayLike)
657660
assert (105,) == z.shape
658-
assert hasattr(z[:], "shape") and (105,) == z[:].shape
661+
assert (105,) == result.shape
659662
assert np.dtype("i4") == z.dtype
660-
assert hasattr(z[:], "dtype") and np.dtype("i4") == z[:].dtype
663+
assert np.dtype("i4") == result.dtype
661664
assert (10,) == z.chunks
662-
np.testing.assert_array_equal(a, z[:])
665+
np.testing.assert_array_equal(a, result)
663666

664667
z.resize(205)
668+
result = z[:]
669+
assert isinstance(result, NDArrayLike)
665670
assert (205,) == z.shape
666-
assert (205,) == z[:].shape
671+
assert (205,) == result.shape
667672
assert np.dtype("i4") == z.dtype
668-
assert np.dtype("i4") == z[:].dtype
673+
assert np.dtype("i4") == result.dtype
669674
assert (10,) == z.chunks
670675
np.testing.assert_array_equal(a, z[:105])
671676
np.testing.assert_array_equal(np.zeros(100, dtype="i4"), z[105:])
672677

673678
z.resize(55)
679+
result = z[:]
680+
assert isinstance(result, NDArrayLike)
674681
assert (55,) == z.shape
675-
assert (55,) == z[:].shape
682+
assert (55,) == result.shape
676683
assert np.dtype("i4") == z.dtype
677-
assert np.dtype("i4") == z[:].dtype
684+
assert np.dtype("i4") == result.dtype
678685
assert (10,) == z.chunks
679-
np.testing.assert_array_equal(a[:55], z[:])
686+
np.testing.assert_array_equal(a[:55], result)
680687

681688
# via shape setter
682689
new_shape = (105,)
683690
z.shape = new_shape
691+
result = z[:]
692+
assert isinstance(result, NDArrayLike)
684693
assert new_shape == z.shape
685-
assert new_shape == z[:].shape
694+
assert new_shape == result.shape
686695

687696

688697
@pytest.mark.parametrize("store", ["memory"], indirect=True)

0 commit comments

Comments
 (0)