Skip to content

Commit 3348439

Browse files
committed
returning npt.ArrayLike instead of NDArrayLike because of scalar return values
1 parent 1a290c7 commit 3348439

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/zarr/core/array.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ async def _get_selection(
12461246
drop_axes=indexer.drop_axes,
12471247
)
12481248
if indexer.shape == ():
1249-
return out_buffer.as_numpy_array().item()
1249+
return cast(out_buffer.as_numpy_array().item(), out_buffer.dtype)
12501250
return out_buffer.as_ndarray_like()
12511251

12521252
async def getitem(
@@ -2209,7 +2209,7 @@ def _iter_chunk_regions(
22092209

22102210
def __array__(
22112211
self, dtype: npt.DTypeLike | None = None, copy: bool | None = None
2212-
) -> NDArrayLike:
2212+
) -> npt.ArrayLike:
22132213
"""
22142214
This method is used by numpy when converting zarr.Array into a numpy array.
22152215
For more information, see https://numpy.org/devdocs/user/basics.interoperability.html#the-array-method
@@ -2220,7 +2220,7 @@ def __array__(
22202220

22212221
arr_np = self[...]
22222222

2223-
if dtype is not None:
2223+
if dtype is not None and hasattr(arr_np, "astype"):
22242224
arr_np = arr_np.astype(dtype)
22252225

22262226
return arr_np

0 commit comments

Comments
 (0)