Skip to content

Commit a557456

Browse files
committed
rename NDArrayOrScalarLike to NDArrayLikeOrScalar
1 parent f03c026 commit a557456

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

src/zarr/api/asynchronous.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from collections.abc import Iterable
3434

3535
from zarr.abc.codec import Codec
36-
from zarr.core.buffer import NDArrayOrScalarLike
36+
from zarr.core.buffer import NDArrayLikeOrScalar
3737
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
3838
from zarr.storage import StoreLike
3939

@@ -233,7 +233,7 @@ async def load(
233233
path: str | None = None,
234234
zarr_format: ZarrFormat | None = None,
235235
zarr_version: ZarrFormat | None = None,
236-
) -> NDArrayOrScalarLike | dict[str, NDArrayOrScalarLike]:
236+
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
237237
"""Load data from an array or group into memory.
238238
239239
Parameters

src/zarr/api/synchronous.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
ShardsLike,
2727
)
2828
from zarr.core.array_spec import ArrayConfig, ArrayConfigLike
29-
from zarr.core.buffer import NDArrayLike, NDArrayOrScalarLike
29+
from zarr.core.buffer import NDArrayLike, NDArrayLikeOrScalar
3030
from zarr.core.chunk_key_encodings import ChunkKeyEncoding, ChunkKeyEncodingLike
3131
from zarr.core.common import (
3232
JSON,
@@ -119,7 +119,7 @@ def load(
119119
path: str | None = None,
120120
zarr_format: ZarrFormat | None = None,
121121
zarr_version: ZarrFormat | None = None,
122-
) -> NDArrayOrScalarLike | dict[str, NDArrayOrScalarLike]:
122+
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
123123
"""Load data from an array or group into memory.
124124
125125
Parameters

src/zarr/core/array.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from zarr.core.buffer import (
3636
BufferPrototype,
3737
NDArrayLike,
38-
NDArrayOrScalarLike,
38+
NDArrayLikeOrScalar,
3939
NDBuffer,
4040
default_buffer_prototype,
4141
)
@@ -1256,7 +1256,7 @@ async def _get_selection(
12561256
prototype: BufferPrototype,
12571257
out: NDBuffer | None = None,
12581258
fields: Fields | None = None,
1259-
) -> NDArrayOrScalarLike:
1259+
) -> NDArrayLikeOrScalar:
12601260
# check fields are sensible
12611261
out_dtype = check_fields(fields, self.dtype)
12621262

@@ -1306,7 +1306,7 @@ async def getitem(
13061306
selection: BasicSelection,
13071307
*,
13081308
prototype: BufferPrototype | None = None,
1309-
) -> NDArrayOrScalarLike:
1309+
) -> NDArrayLikeOrScalar:
13101310
"""
13111311
Asynchronous function that retrieves a subset of the array's data based on the provided selection.
13121312
@@ -2278,7 +2278,7 @@ def __array__(
22782278

22792279
return arr_np
22802280

2281-
def __getitem__(self, selection: Selection) -> NDArrayOrScalarLike:
2281+
def __getitem__(self, selection: Selection) -> NDArrayLikeOrScalar:
22822282
"""Retrieve data for an item or region of the array.
22832283
22842284
Parameters
@@ -2536,7 +2536,7 @@ def get_basic_selection(
25362536
out: NDBuffer | None = None,
25372537
prototype: BufferPrototype | None = None,
25382538
fields: Fields | None = None,
2539-
) -> NDArrayOrScalarLike:
2539+
) -> NDArrayLikeOrScalar:
25402540
"""Retrieve data for an item or region of the array.
25412541
25422542
Parameters
@@ -2756,7 +2756,7 @@ def get_orthogonal_selection(
27562756
out: NDBuffer | None = None,
27572757
fields: Fields | None = None,
27582758
prototype: BufferPrototype | None = None,
2759-
) -> NDArrayOrScalarLike:
2759+
) -> NDArrayLikeOrScalar:
27602760
"""Retrieve data by making a selection for each dimension of the array. For
27612761
example, if an array has 2 dimensions, allows selecting specific rows and/or
27622762
columns. The selection for each dimension can be either an integer (indexing a
@@ -2992,7 +2992,7 @@ def get_mask_selection(
29922992
out: NDBuffer | None = None,
29932993
fields: Fields | None = None,
29942994
prototype: BufferPrototype | None = None,
2995-
) -> NDArrayOrScalarLike:
2995+
) -> NDArrayLikeOrScalar:
29962996
"""Retrieve a selection of individual items, by providing a Boolean array of the
29972997
same shape as the array against which the selection is being made, where True
29982998
values indicate a selected item.
@@ -3154,7 +3154,7 @@ def get_coordinate_selection(
31543154
out: NDBuffer | None = None,
31553155
fields: Fields | None = None,
31563156
prototype: BufferPrototype | None = None,
3157-
) -> NDArrayOrScalarLike:
3157+
) -> NDArrayLikeOrScalar:
31583158
"""Retrieve a selection of individual items, by providing the indices
31593159
(coordinates) for each selected item.
31603160
@@ -3342,7 +3342,7 @@ def get_block_selection(
33423342
out: NDBuffer | None = None,
33433343
fields: Fields | None = None,
33443344
prototype: BufferPrototype | None = None,
3345-
) -> NDArrayOrScalarLike:
3345+
) -> NDArrayLikeOrScalar:
33463346
"""Retrieve a selection of individual items, by providing the indices
33473347
(coordinates) for each selected item.
33483348

src/zarr/core/buffer/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Buffer,
44
BufferPrototype,
55
NDArrayLike,
6-
NDArrayOrScalarLike,
6+
NDArrayLikeOrScalar,
77
NDBuffer,
88
default_buffer_prototype,
99
)
@@ -14,7 +14,7 @@
1414
"Buffer",
1515
"BufferPrototype",
1616
"NDArrayLike",
17-
"NDArrayOrScalarLike",
17+
"NDArrayLikeOrScalar",
1818
"NDBuffer",
1919
"default_buffer_prototype",
2020
"numpy_buffer_prototype",

src/zarr/core/buffer/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __eq__(self, other: object) -> Self: # type: ignore[explicit-override, over
106106

107107

108108
ScalarType = int | float | complex | bytes | str | bool | np.generic
109-
NDArrayOrScalarLike = ScalarType | NDArrayLike
109+
NDArrayLikeOrScalar = ScalarType | NDArrayLike
110110

111111

112112
def check_item_key_is_1d_contiguous(key: Any) -> None:

src/zarr/core/indexing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
if TYPE_CHECKING:
3131
from zarr.core.array import Array
32-
from zarr.core.buffer import NDArrayOrScalarLike
32+
from zarr.core.buffer import NDArrayLikeOrScalar
3333
from zarr.core.chunk_grids import ChunkGrid
3434
from zarr.core.common import ChunkCoords
3535

@@ -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) -> NDArrayOrScalarLike:
932+
def __getitem__(self, selection: OrthogonalSelection | Array) -> NDArrayLikeOrScalar:
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) -> NDArrayOrScalarLike:
1041+
def __getitem__(self, selection: BasicSelection) -> NDArrayLikeOrScalar:
10421042
fields, new_selection = pop_fields(selection)
10431043
new_selection = ensure_tuple(new_selection)
10441044
new_selection = replace_lists(new_selection)
@@ -1229,7 +1229,7 @@ class VIndex:
12291229
# TODO: develop Array generic and move zarr.Array[np.intp] | zarr.Array[np.bool_] to ArrayOfIntOrBool
12301230
def __getitem__(
12311231
self, selection: CoordinateSelection | MaskSelection | Array
1232-
) -> NDArrayOrScalarLike:
1232+
) -> NDArrayLikeOrScalar:
12331233
from zarr.core.array import Array
12341234

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

tests/test_array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
chunks_initialized,
3838
create_array,
3939
)
40-
from zarr.core.buffer import NDArrayLike, NDArrayOrScalarLike, default_buffer_prototype
40+
from zarr.core.buffer import NDArrayLike, NDArrayLikeOrScalar, default_buffer_prototype
4141
from zarr.core.buffer.cpu import NDBuffer
4242
from zarr.core.chunk_grids import _auto_partition
4343
from zarr.core.common import JSON, MemoryOrder, ZarrFormat
@@ -1354,7 +1354,7 @@ def test_scalar_array(value: Any, zarr_format: ZarrFormat) -> None:
13541354
assert arr[...] == value
13551355
assert arr.shape == ()
13561356
assert arr.ndim == 0
1357-
assert isinstance(arr[()], NDArrayOrScalarLike)
1357+
assert isinstance(arr[()], NDArrayLikeOrScalar)
13581358

13591359

13601360
async def test_orthogonal_set_total_slice() -> None:

0 commit comments

Comments
 (0)