Skip to content

Commit afdbb75

Browse files
authored
Add some more numpydoc rules/associated fixes (#2399)
* Add GL09 validation * Add SS02 rule * Add SS04 * Enable PR02 rule
1 parent 5f3a512 commit afdbb75

File tree

17 files changed

+137
-149
lines changed

17 files changed

+137
-149
lines changed

pyproject.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,4 +329,15 @@ ignore = [
329329

330330
[tool.numpydoc_validation]
331331
# 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"]
332+
checks = [
333+
"GL06",
334+
"GL07",
335+
"GL09",
336+
"GL10",
337+
"SS02",
338+
"SS04",
339+
"PR02",
340+
"PR03",
341+
"PR05",
342+
"PR06",
343+
]

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def with_mode(self, mode: AccessModeLiteral) -> Self:
162162
163163
Parameters
164164
----------
165-
mode: AccessModeLiteral
165+
mode : AccessModeLiteral
166166
The new mode to use.
167167
168168
Returns

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: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ class AsyncArray(Generic[T_ArrayMetadata]):
184184
The metadata of the array.
185185
store_path : StorePath
186186
The path to the Zarr store.
187-
codec_pipeline : CodecPipeline, optional
188-
The codec pipeline used for encoding and decoding chunks, by default None.
189187
order : {'C', 'F'}, optional
190188
The order of the array data in memory, by default None.
191189
@@ -857,9 +855,9 @@ def _iter_chunk_coords(
857855
858856
Parameters
859857
----------
860-
origin: Sequence[int] | None, default=None
858+
origin : Sequence[int] | None, default=None
861859
The origin of the selection relative to the array's chunk grid.
862-
selection_shape: Sequence[int] | None, default=None
860+
selection_shape : Sequence[int] | None, default=None
863861
The shape of the selection in chunk grid coordinates.
864862
865863
Yields
@@ -878,9 +876,9 @@ def _iter_chunk_keys(
878876
879877
Parameters
880878
----------
881-
origin: Sequence[int] | None, default=None
879+
origin : Sequence[int] | None, default=None
882880
The origin of the selection relative to the array's chunk grid.
883-
selection_shape: Sequence[int] | None, default=None
881+
selection_shape : Sequence[int] | None, default=None
884882
The shape of the selection in chunk grid coordinates.
885883
886884
Yields
@@ -901,9 +899,9 @@ def _iter_chunk_regions(
901899
902900
Parameters
903901
----------
904-
origin: Sequence[int] | None, default=None
902+
origin : Sequence[int] | None, default=None
905903
The origin of the selection relative to the array's chunk grid.
906-
selection_shape: Sequence[int] | None, default=None
904+
selection_shape : Sequence[int] | None, default=None
907905
The shape of the selection in chunk grid coordinates.
908906
909907
Yields
@@ -1151,17 +1149,7 @@ async def info(self) -> None:
11511149

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

11661154
_async_array: AsyncArray[ArrayV3Metadata] | AsyncArray[ArrayV2Metadata]
11671155

@@ -1419,9 +1407,9 @@ def _iter_chunk_coords(
14191407
14201408
Parameters
14211409
----------
1422-
origin: Sequence[int] | None, default=None
1410+
origin : Sequence[int] | None, default=None
14231411
The origin of the selection relative to the array's chunk grid.
1424-
selection_shape: Sequence[int] | None, default=None
1412+
selection_shape : Sequence[int] | None, default=None
14251413
The shape of the selection in chunk grid coordinates.
14261414
14271415
Yields
@@ -1456,9 +1444,9 @@ def _iter_chunk_keys(
14561444
14571445
Parameters
14581446
----------
1459-
origin: Sequence[int] | None, default=None
1447+
origin : Sequence[int] | None, default=None
14601448
The origin of the selection relative to the array's chunk grid.
1461-
selection_shape: Sequence[int] | None, default=None
1449+
selection_shape : Sequence[int] | None, default=None
14621450
The shape of the selection in chunk grid coordinates.
14631451
14641452
Yields
@@ -1478,9 +1466,9 @@ def _iter_chunk_regions(
14781466
14791467
Parameters
14801468
----------
1481-
origin: Sequence[int] | None, default=None
1469+
origin : Sequence[int] | None, default=None
14821470
The origin of the selection relative to the array's chunk grid.
1483-
selection_shape: Sequence[int] | None, default=None
1471+
selection_shape : Sequence[int] | None, default=None
14841472
The shape of the selection in chunk grid coordinates.
14851473
14861474
Yields
@@ -2231,7 +2219,7 @@ def get_mask_selection(
22312219
22322220
Parameters
22332221
----------
2234-
selection : ndarray, bool
2222+
mask : ndarray, bool
22352223
A Boolean array of the same shape as the array against which the selection is
22362224
being made.
22372225
out : NDBuffer, optional
@@ -2314,7 +2302,7 @@ def set_mask_selection(
23142302
23152303
Parameters
23162304
----------
2317-
selection : ndarray, bool
2305+
mask : ndarray, bool
23182306
A Boolean array of the same shape as the array against which the selection is
23192307
being made.
23202308
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

src/zarr/core/chunk_grids.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ def _guess_chunks(
4242
4343
Parameters
4444
----------
45-
shape: ChunkCoords
45+
shape : ChunkCoords
4646
The chunk shape.
47-
typesize: int
47+
typesize : int
4848
The size, in bytes, of each element of the chunk.
49-
increment_bytes: int = 256 * 1024
49+
increment_bytes : int = 256 * 1024
5050
The number of bytes used to increment or decrement the target chunk size in bytes.
51-
min_bytes: int = 128 * 1024
51+
min_bytes : int = 128 * 1024
5252
The soft lower bound on the final chunk size in bytes.
53-
max_bytes: int = 64 * 1024 * 1024
53+
max_bytes : int = 64 * 1024 * 1024
5454
The hard upper bound on the final chunk size in bytes.
5555
5656
Returns

0 commit comments

Comments
 (0)