Skip to content

Commit 1a290c7

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

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/zarr/api/asynchronous.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ async def load(
232232
path: str | None = None,
233233
zarr_format: ZarrFormat | None = None,
234234
zarr_version: ZarrFormat | None = None,
235-
) -> NDArrayLike | dict[str, NDArrayLike]:
235+
) -> npt.ArrayLike | dict[str, npt.ArrayLike]:
236236
"""Load data from an array or group into memory.
237237
238238
Parameters

src/zarr/core/array.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ async def _get_selection(
12041204
prototype: BufferPrototype,
12051205
out: NDBuffer | None = None,
12061206
fields: Fields | None = None,
1207-
) -> NDArrayLike:
1207+
) -> npt.ArrayLike:
12081208
# check fields are sensible
12091209
out_dtype = check_fields(fields, self.dtype)
12101210

@@ -1254,7 +1254,7 @@ async def getitem(
12541254
selection: BasicSelection,
12551255
*,
12561256
prototype: BufferPrototype | None = None,
1257-
) -> NDArrayLike:
1257+
) -> npt.ArrayLike:
12581258
"""
12591259
Asynchronous function that retrieves a subset of the array's data based on the provided selection.
12601260
@@ -1267,7 +1267,7 @@ async def getitem(
12671267
12681268
Returns
12691269
-------
1270-
NDArrayLike
1270+
npt.ArrayLike
12711271
The retrieved subset of the array's data.
12721272
12731273
Examples
@@ -2225,7 +2225,7 @@ def __array__(
22252225

22262226
return arr_np
22272227

2228-
def __getitem__(self, selection: Selection) -> NDArrayLike:
2228+
def __getitem__(self, selection: Selection) -> npt.ArrayLike:
22292229
"""Retrieve data for an item or region of the array.
22302230
22312231
Parameters
@@ -2236,7 +2236,7 @@ def __getitem__(self, selection: Selection) -> NDArrayLike:
22362236
22372237
Returns
22382238
-------
2239-
NDArrayLike
2239+
npt.ArrayLike
22402240
An array-like containing the data for the requested region.
22412241
22422242
Examples
@@ -2483,7 +2483,7 @@ def get_basic_selection(
24832483
out: NDBuffer | None = None,
24842484
prototype: BufferPrototype | None = None,
24852485
fields: Fields | None = None,
2486-
) -> NDArrayLike:
2486+
) -> npt.ArrayLike:
24872487
"""Retrieve data for an item or region of the array.
24882488
24892489
Parameters
@@ -2703,7 +2703,7 @@ def get_orthogonal_selection(
27032703
out: NDBuffer | None = None,
27042704
fields: Fields | None = None,
27052705
prototype: BufferPrototype | None = None,
2706-
) -> NDArrayLike:
2706+
) -> npt.ArrayLike:
27072707
"""Retrieve data by making a selection for each dimension of the array. For
27082708
example, if an array has 2 dimensions, allows selecting specific rows and/or
27092709
columns. The selection for each dimension can be either an integer (indexing a
@@ -2939,7 +2939,7 @@ def get_mask_selection(
29392939
out: NDBuffer | None = None,
29402940
fields: Fields | None = None,
29412941
prototype: BufferPrototype | None = None,
2942-
) -> NDArrayLike:
2942+
) -> npt.ArrayLike:
29432943
"""Retrieve a selection of individual items, by providing a Boolean array of the
29442944
same shape as the array against which the selection is being made, where True
29452945
values indicate a selected item.
@@ -3101,7 +3101,7 @@ def get_coordinate_selection(
31013101
out: NDBuffer | None = None,
31023102
fields: Fields | None = None,
31033103
prototype: BufferPrototype | None = None,
3104-
) -> NDArrayLike:
3104+
) -> npt.ArrayLike:
31053105
"""Retrieve a selection of individual items, by providing the indices
31063106
(coordinates) for each selected item.
31073107
@@ -3289,7 +3289,7 @@ def get_block_selection(
32893289
out: NDBuffer | None = None,
32903290
fields: Fields | None = None,
32913291
prototype: BufferPrototype | None = None,
3292-
) -> NDArrayLike:
3292+
) -> npt.ArrayLike:
32933293
"""Retrieve a selection of individual items, by providing the indices
32943294
(coordinates) for each selected item.
32953295
@@ -3307,7 +3307,7 @@ def get_block_selection(
33073307
33083308
Returns
33093309
-------
3310-
NDArrayLike
3310+
npt.ArrayLike
33113311
An array-like containing the data for the requested block selection.
33123312
33133313
Examples

src/zarr/core/indexing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ class OIndex:
929929
array: Array
930930

931931
# TODO: develop Array generic and move zarr.Array[np.intp] | zarr.Array[np.bool_] to ArrayOfIntOrBool
932-
def __getitem__(self, selection: OrthogonalSelection | Array) -> NDArrayLike:
932+
def __getitem__(self, selection: OrthogonalSelection | Array) -> npt.ArrayLike:
933933
from zarr.core.array import Array
934934

935935
# if input is a Zarr array, we materialize it now.
@@ -1038,7 +1038,7 @@ def __iter__(self) -> Iterator[ChunkProjection]:
10381038
class BlockIndex:
10391039
array: Array
10401040

1041-
def __getitem__(self, selection: BasicSelection) -> NDArrayLike:
1041+
def __getitem__(self, selection: BasicSelection) -> npt.ArrayLike:
10421042
fields, new_selection = pop_fields(selection)
10431043
new_selection = ensure_tuple(new_selection)
10441044
new_selection = replace_lists(new_selection)
@@ -1227,7 +1227,7 @@ class VIndex:
12271227
array: Array
12281228

12291229
# TODO: develop Array generic and move zarr.Array[np.intp] | zarr.Array[np.bool_] to ArrayOfIntOrBool
1230-
def __getitem__(self, selection: CoordinateSelection | MaskSelection | Array) -> NDArrayLike:
1230+
def __getitem__(self, selection: CoordinateSelection | MaskSelection | Array) -> npt.ArrayLike:
12311231
from zarr.core.array import Array
12321232

12331233
# if input is a Zarr array, we materialize it now.

0 commit comments

Comments
 (0)