Skip to content

Commit afe7a33

Browse files
committed
Revert "fix: some NDArrayLike fixes"
This reverts commit 73b72b1.
1 parent b030957 commit afe7a33

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

src/zarr/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _reshape_view(arr: "NDArray[Any]", shape: tuple[int, ...]) -> "NDArray[Any]"
102102
If a view cannot be created (the array is not contiguous) on NumPy >= 2.1.
103103
"""
104104
if Version(np.__version__) >= Version("2.1"):
105-
return arr.reshape(shape, copy=False)
105+
return arr.reshape(shape, copy=False) # type: ignore[call-overload, no-any-return]
106106
else:
107107
arr.shape = shape
108108
return arr

src/zarr/core/buffer/core.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,7 @@ def __setitem__(self, key: slice, value: Any) -> None: ...
7171
def __array__(self) -> npt.NDArray[Any]: ...
7272

7373
def reshape(
74-
self,
75-
shape: Sequence[SupportsIndex] | SupportsIndex,
76-
/,
77-
*,
78-
order: Literal["A", "C", "F"] | None = ...,
79-
copy: bool | None = ...,
74+
self, shape: tuple[int, ...] | Literal[-1], *, order: Literal["A", "C", "F"] = ...
8075
) -> Self: ...
8176

8277
def view(self, dtype: npt.DTypeLike) -> Self: ...
@@ -95,16 +90,9 @@ def copy(self) -> Self: ...
9590

9691
def transpose(self, axes: SupportsIndex | Sequence[SupportsIndex] | None) -> Self: ...
9792

98-
def ravel(self, order: Literal["K", "A", "C", "F"] | None = ...) -> Self: ...
93+
def ravel(self, order: Literal["K", "A", "C", "F"] = ...) -> Self: ...
9994

100-
def all(
101-
self,
102-
axis: int | tuple[int, ...] | None = ...,
103-
out: NDArrayLike | None = ...,
104-
keepdims: Literal[False, 0] = ...,
105-
*,
106-
where: bool = ...,
107-
) -> bool: ...
95+
def all(self) -> bool: ...
10896

10997
def __eq__(self, other: object) -> Self: # type: ignore[override]
11098
"""Element-wise equal

tests/test_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import inspect
44
import re
5-
from typing import TYPE_CHECKING, Any, cast
5+
from typing import TYPE_CHECKING, Any
66

77
import zarr.codecs
88
import zarr.storage
@@ -558,7 +558,7 @@ def test_load_array(sync_store: Store) -> None:
558558

559559
# can also load arrays directly into a numpy array
560560
for array_name in ["foo", "bar"]:
561-
array = cast(np.ndarray, load(store, path=array_name))
561+
array = load(store, path=array_name)
562562
assert isinstance(array, np.ndarray)
563563
if array_name == "foo":
564564
assert_array_equal(foo, array)
@@ -575,11 +575,11 @@ def test_load_zip(tmp_path: Path, path: str | None, load_read_only: bool | None)
575575
with ZipStore(file, mode="w", read_only=False) as zs:
576576
save(zs, data, path=path)
577577
with ZipStore(file, mode="r", read_only=load_read_only) as zs:
578-
result = cast(np.ndarray, zarr.load(store=zs, path=path))
578+
result = zarr.load(store=zs, path=path)
579579
assert isinstance(result, np.ndarray)
580580
assert np.array_equal(result, data)
581581
with ZipStore(file, read_only=load_read_only) as zs:
582-
result = cast(np.ndarray, zarr.load(store=zs, path=path))
582+
result = zarr.load(store=zs, path=path)
583583
assert isinstance(result, np.ndarray)
584584
assert np.array_equal(result, data)
585585

@@ -593,7 +593,7 @@ def test_load_local(tmp_path: Path, path: str | None, load_read_only: bool) -> N
593593
with LocalStore(file, read_only=False) as zs:
594594
save(zs, data, path=path)
595595
with LocalStore(file, read_only=load_read_only) as zs:
596-
result = cast(np.ndarray, zarr.load(store=zs, path=path))
596+
result = zarr.load(store=zs, path=path)
597597
assert isinstance(result, np.ndarray)
598598
assert np.array_equal(result, data)
599599

tests/test_codecs/test_codecs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import json
44
from dataclasses import dataclass
5-
from typing import TYPE_CHECKING, Any, cast
5+
from typing import TYPE_CHECKING, Any
66

77
import numpy as np
88
import pytest
@@ -145,7 +145,7 @@ def test_order_implicit(
145145

146146
with config.set({"array.order": runtime_read_order}):
147147
a = Array.open(spath)
148-
read_data = cast(np.ndarray, a[:, :])
148+
read_data = a[:, :]
149149
assert np.array_equal(data, read_data)
150150

151151
assert isinstance(read_data, np.ndarray)

0 commit comments

Comments
 (0)