Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3348439

Browse filesBrowse files
committed
returning npt.ArrayLike instead of NDArrayLike because of scalar return values
1 parent 1a290c7 commit 3348439
Copy full SHA for 3348439

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed

‎src/zarr/core/array.py

Copy file name to clipboardExpand all lines: src/zarr/core/array.py
+3-3Lines changed: 3 additions & 3 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.