Skip to content

Commit f8f1ab9

Browse files
authored
Merge branch 'main' into fix/runtime-order
2 parents a6f345b + 9dd9ac6 commit f8f1ab9

File tree

20 files changed

+162
-167
lines changed

20 files changed

+162
-167
lines changed

pyproject.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ extend-select = [
214214
"B", # flake8-bugbear
215215
"C4", # flake8-comprehensions
216216
"FLY", # flynt
217+
"FURB", # refurb
217218
"G", # flake8-logging-format
218219
"I", # isort
219220
"ISC", # flake8-implicit-str-concat
@@ -329,4 +330,15 @@ ignore = [
329330

330331
[tool.numpydoc_validation]
331332
# See https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks for list of checks
332-
checks = ["GL06", "GL07", "GL10", "PR03", "PR05", "PR06"]
333+
checks = [
334+
"GL06",
335+
"GL07",
336+
"GL09",
337+
"GL10",
338+
"SS02",
339+
"SS04",
340+
"PR02",
341+
"PR03",
342+
"PR05",
343+
"PR06",
344+
]

src/zarr/abc/codec.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
8585
8686
Parameters
8787
----------
88-
chunk_spec : ArraySpec
88+
array_spec : ArraySpec
8989
9090
Returns
9191
-------
@@ -99,11 +99,11 @@ def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: Chun
9999
100100
Parameters
101101
----------
102-
shape: ChunkCoords
102+
shape : ChunkCoords
103103
The array shape
104-
dtype: np.dtype[Any]
104+
dtype : np.dtype[Any]
105105
The array data type
106-
chunk_grid: ChunkGrid
106+
chunk_grid : ChunkGrid
107107
The array chunk grid
108108
"""
109109
...
@@ -292,11 +292,11 @@ def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: Chun
292292
293293
Parameters
294294
----------
295-
shape: ChunkCoords
295+
shape : ChunkCoords
296296
The array shape
297-
dtype: np.dtype[Any]
297+
dtype : np.dtype[Any]
298298
The array data type
299-
chunk_grid: ChunkGrid
299+
chunk_grid : ChunkGrid
300300
The array chunk grid
301301
"""
302302
...
@@ -308,7 +308,7 @@ def compute_encoded_size(self, byte_length: int, array_spec: ArraySpec) -> int:
308308
309309
Parameters
310310
----------
311-
input_byte_length : int
311+
byte_length : int
312312
array_spec : ArraySpec
313313
314314
Returns
@@ -327,7 +327,7 @@ async def decode(
327327
328328
Parameters
329329
----------
330-
chunks_and_specs : Iterable[tuple[Buffer | None, ArraySpec]]
330+
chunk_bytes_and_specs : Iterable[tuple[Buffer | None, ArraySpec]]
331331
Ordered set of encoded chunks with their accompanying chunk spec.
332332
333333
Returns
@@ -346,7 +346,7 @@ async def encode(
346346
347347
Parameters
348348
----------
349-
chunks_and_specs : Iterable[tuple[NDBuffer | None, ArraySpec]]
349+
chunk_arrays_and_specs : Iterable[tuple[NDBuffer | None, ArraySpec]]
350350
Ordered set of to-be-encoded chunks with their accompanying chunk spec.
351351
352352
Returns

src/zarr/abc/store.py

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

33
from abc import ABC, abstractmethod
44
from asyncio import gather
5+
from itertools import starmap
56
from typing import TYPE_CHECKING, NamedTuple, Protocol, runtime_checkable
67

78
if TYPE_CHECKING:
@@ -162,7 +163,7 @@ def with_mode(self, mode: AccessModeLiteral) -> Self:
162163
163164
Parameters
164165
----------
165-
mode: AccessModeLiteral
166+
mode : AccessModeLiteral
166167
The new mode to use.
167168
168169
Returns
@@ -282,7 +283,7 @@ async def _set_many(self, values: Iterable[tuple[str, Buffer]]) -> None:
282283
"""
283284
Insert multiple (key, value) pairs into storage.
284285
"""
285-
await gather(*(self.set(key, value) for key, value in values))
286+
await gather(*starmap(self.set, values))
286287
return
287288

288289
@property

src/zarr/api/asynchronous.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969

7070
def _get_shape_chunks(a: ArrayLike | Any) -> tuple[ChunkCoords | None, ChunkCoords | None]:
71-
"""helper function to get the shape and chunks from an array-like object"""
71+
"""Helper function to get the shape and chunks from an array-like object"""
7272
shape = None
7373
chunks = None
7474

@@ -86,7 +86,7 @@ def _get_shape_chunks(a: ArrayLike | Any) -> tuple[ChunkCoords | None, ChunkCoor
8686

8787

8888
def _like_args(a: ArrayLike, kwargs: dict[str, Any]) -> dict[str, Any]:
89-
"""set default values for shape and chunks if they are not present in the array-like object"""
89+
"""Set default values for shape and chunks if they are not present in the array-like object"""
9090

9191
new = kwargs.copy()
9292

@@ -121,7 +121,7 @@ def _like_args(a: ArrayLike, kwargs: dict[str, Any]) -> dict[str, Any]:
121121
def _handle_zarr_version_or_format(
122122
*, zarr_version: ZarrFormat | None, zarr_format: ZarrFormat | None
123123
) -> ZarrFormat | None:
124-
"""handle the deprecated zarr_version kwarg and return zarr_format"""
124+
"""Handle the deprecated zarr_version kwarg and return zarr_format"""
125125
if zarr_format is not None and zarr_version is not None and zarr_format != zarr_version:
126126
raise ValueError(
127127
f"zarr_format {zarr_format} does not match zarr_version {zarr_version}, please only set one"
@@ -135,7 +135,7 @@ def _handle_zarr_version_or_format(
135135

136136

137137
def _default_zarr_version() -> ZarrFormat:
138-
"""return the default zarr_version"""
138+
"""Return the default zarr_version"""
139139
return cast(ZarrFormat, int(config.get("default_zarr_version", 3)))
140140

141141

@@ -152,9 +152,9 @@ async def consolidate_metadata(
152152
153153
Parameters
154154
----------
155-
store: StoreLike
155+
store : StoreLike
156156
The store-like object whose metadata you wish to consolidate.
157-
path: str, optional
157+
path : str, optional
158158
A path to a group in the store to consolidate at. Only children
159159
below that group will be consolidated.
160160
@@ -341,13 +341,13 @@ async def save(
341341
----------
342342
store : Store or str
343343
Store or path to directory in file system or name of zip file.
344-
args : ndarray
344+
*args : ndarray
345345
NumPy arrays with data to save.
346346
zarr_format : {2, 3, None}, optional
347347
The zarr format to use when saving.
348348
path : str or None, optional
349349
The path within the group where the arrays will be saved.
350-
kwargs
350+
**kwargs
351351
NumPy arrays with data to save.
352352
"""
353353
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
@@ -386,7 +386,7 @@ async def save_array(
386386
storage_options : dict
387387
If using an fsspec URL to create the store, these will be passed to
388388
the backend implementation. Ignored otherwise.
389-
kwargs
389+
**kwargs
390390
Passed through to :func:`create`, e.g., compressor.
391391
"""
392392
zarr_format = (
@@ -423,7 +423,7 @@ async def save_group(
423423
----------
424424
store : Store or str
425425
Store or path to directory in file system or name of zip file.
426-
args : ndarray
426+
*args : ndarray
427427
NumPy arrays with data to save.
428428
zarr_format : {2, 3, None}, optional
429429
The zarr format to use when saving.
@@ -432,7 +432,7 @@ async def save_group(
432432
storage_options : dict
433433
If using an fsspec URL to create the store, these will be passed to
434434
the backend implementation. Ignored otherwise.
435-
kwargs
435+
**kwargs
436436
NumPy arrays with data to save.
437437
"""
438438
zarr_format = (
@@ -479,7 +479,7 @@ async def array(
479479
----------
480480
data : array_like
481481
The data to fill the array with.
482-
kwargs
482+
**kwargs
483483
Passed through to :func:`create`.
484484
485485
Returns

src/zarr/core/array.py

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
from asyncio import gather
55
from dataclasses import dataclass, field, replace
6+
from itertools import starmap
67
from logging import getLogger
78
from typing import TYPE_CHECKING, Any, Generic, Literal, cast, overload
89

@@ -184,8 +185,6 @@ class AsyncArray(Generic[T_ArrayMetadata]):
184185
The metadata of the array.
185186
store_path : StorePath
186187
The path to the Zarr store.
187-
codec_pipeline : CodecPipeline, optional
188-
The codec pipeline used for encoding and decoding chunks, by default None.
189188
order : {'C', 'F'}, optional
190189
The order of the array data in memory, by default None.
191190
@@ -816,7 +815,7 @@ def cdata_shape(self) -> ChunkCoords:
816815
Tuple[int]
817816
The shape of the chunk grid for this array.
818817
"""
819-
return tuple(ceildiv(s, c) for s, c in zip(self.shape, self.chunks, strict=False))
818+
return tuple(starmap(ceildiv, zip(self.shape, self.chunks, strict=False)))
820819

821820
@property
822821
def nchunks(self) -> int:
@@ -855,9 +854,9 @@ def _iter_chunk_coords(
855854
856855
Parameters
857856
----------
858-
origin: Sequence[int] | None, default=None
857+
origin : Sequence[int] | None, default=None
859858
The origin of the selection relative to the array's chunk grid.
860-
selection_shape: Sequence[int] | None, default=None
859+
selection_shape : Sequence[int] | None, default=None
861860
The shape of the selection in chunk grid coordinates.
862861
863862
Yields
@@ -876,9 +875,9 @@ def _iter_chunk_keys(
876875
877876
Parameters
878877
----------
879-
origin: Sequence[int] | None, default=None
878+
origin : Sequence[int] | None, default=None
880879
The origin of the selection relative to the array's chunk grid.
881-
selection_shape: Sequence[int] | None, default=None
880+
selection_shape : Sequence[int] | None, default=None
882881
The shape of the selection in chunk grid coordinates.
883882
884883
Yields
@@ -899,9 +898,9 @@ def _iter_chunk_regions(
899898
900899
Parameters
901900
----------
902-
origin: Sequence[int] | None, default=None
901+
origin : Sequence[int] | None, default=None
903902
The origin of the selection relative to the array's chunk grid.
904-
selection_shape: Sequence[int] | None, default=None
903+
selection_shape : Sequence[int] | None, default=None
905904
The shape of the selection in chunk grid coordinates.
906905
907906
Yields
@@ -1149,17 +1148,7 @@ async def info(self) -> None:
11491148

11501149
@dataclass(frozen=True)
11511150
class Array:
1152-
"""Instantiate an array from an initialized store.
1153-
1154-
Parameters
1155-
----------
1156-
store : StoreLike
1157-
The array store that has already been initialized.
1158-
shape : ChunkCoords
1159-
The shape of the array.
1160-
dtype : npt.DTypeLike
1161-
The dtype of the array.
1162-
"""
1151+
"""Instantiate an array from an initialized store."""
11631152

11641153
_async_array: AsyncArray[ArrayV3Metadata] | AsyncArray[ArrayV2Metadata]
11651154

@@ -1395,7 +1384,7 @@ def cdata_shape(self) -> ChunkCoords:
13951384
"""
13961385
The shape of the chunk grid for this array.
13971386
"""
1398-
return tuple(ceildiv(s, c) for s, c in zip(self.shape, self.chunks, strict=False))
1387+
return tuple(starmap(ceildiv, zip(self.shape, self.chunks, strict=False)))
13991388

14001389
@property
14011390
def nchunks(self) -> int:
@@ -1417,9 +1406,9 @@ def _iter_chunk_coords(
14171406
14181407
Parameters
14191408
----------
1420-
origin: Sequence[int] | None, default=None
1409+
origin : Sequence[int] | None, default=None
14211410
The origin of the selection relative to the array's chunk grid.
1422-
selection_shape: Sequence[int] | None, default=None
1411+
selection_shape : Sequence[int] | None, default=None
14231412
The shape of the selection in chunk grid coordinates.
14241413
14251414
Yields
@@ -1454,9 +1443,9 @@ def _iter_chunk_keys(
14541443
14551444
Parameters
14561445
----------
1457-
origin: Sequence[int] | None, default=None
1446+
origin : Sequence[int] | None, default=None
14581447
The origin of the selection relative to the array's chunk grid.
1459-
selection_shape: Sequence[int] | None, default=None
1448+
selection_shape : Sequence[int] | None, default=None
14601449
The shape of the selection in chunk grid coordinates.
14611450
14621451
Yields
@@ -1476,9 +1465,9 @@ def _iter_chunk_regions(
14761465
14771466
Parameters
14781467
----------
1479-
origin: Sequence[int] | None, default=None
1468+
origin : Sequence[int] | None, default=None
14801469
The origin of the selection relative to the array's chunk grid.
1481-
selection_shape: Sequence[int] | None, default=None
1470+
selection_shape : Sequence[int] | None, default=None
14821471
The shape of the selection in chunk grid coordinates.
14831472
14841473
Yields
@@ -2229,7 +2218,7 @@ def get_mask_selection(
22292218
22302219
Parameters
22312220
----------
2232-
selection : ndarray, bool
2221+
mask : ndarray, bool
22332222
A Boolean array of the same shape as the array against which the selection is
22342223
being made.
22352224
out : NDBuffer, optional
@@ -2312,7 +2301,7 @@ def set_mask_selection(
23122301
23132302
Parameters
23142303
----------
2315-
selection : ndarray, bool
2304+
mask : ndarray, bool
23162305
A Boolean array of the same shape as the array against which the selection is
23172306
being made.
23182307
value : npt.ArrayLike

src/zarr/core/buffer/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class NDBuffer:
308308
309309
Parameters
310310
----------
311-
ndarray_like
311+
array : ndarray_like
312312
ndarray-like object that is convertible to a regular Numpy array.
313313
"""
314314

src/zarr/core/buffer/cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class NDBuffer(core.NDBuffer):
138138
139139
Parameters
140140
----------
141-
ndarray_like
141+
array
142142
ndarray-like object that is convertible to a regular Numpy array.
143143
"""
144144

src/zarr/core/buffer/gpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class NDBuffer(core.NDBuffer):
132132
133133
Parameters
134134
----------
135-
ndarray_like
135+
array
136136
ndarray-like object that is convertible to a regular Numpy array.
137137
"""
138138

0 commit comments

Comments
 (0)