Skip to content

Commit 9bce890

Browse files
authored
Add some numpydoc validation checks (#2316)
1 parent 75a5a2a commit 9bce890

File tree

6 files changed

+56
-48
lines changed

6 files changed

+56
-48
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ repos:
4949
hooks:
5050
- id: rst-directive-colons
5151
- id: rst-inline-touching-normal
52+
- repo: https://github.com/numpy/numpydoc
53+
rev: v1.8.0
54+
hooks:
55+
- id: numpydoc-validation

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,7 @@ ignore = [
319319
"PC111", # fix Python code in documentation - enable later
320320
"PC180", # for JavaScript - not interested
321321
]
322+
323+
[tool.numpydoc_validation]
324+
# See https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks for list of checks
325+
checks = ["GL06", "GL07", "GL10", "PR03", "PR05", "PR06"]

src/zarr/api/asynchronous.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async def load(
159159
160160
Parameters
161161
----------
162-
store : Store or string
162+
store : Store or str
163163
Store or path to directory in file system or name of zip file.
164164
path : str or None, optional
165165
The path within the store from which to load.
@@ -203,7 +203,7 @@ async def open(
203203
204204
Parameters
205205
----------
206-
store : Store or string, optional
206+
store : Store or str, optional
207207
Store or path to directory in file system or name of zip file.
208208
mode : {'r', 'r+', 'a', 'w', 'w-'}, optional
209209
Persistence mode: 'r' means read only (must exist); 'r+' means
@@ -267,7 +267,7 @@ async def save(
267267
268268
Parameters
269269
----------
270-
store : Store or string
270+
store : Store or str
271271
Store or path to directory in file system or name of zip file.
272272
args : ndarray
273273
NumPy arrays with data to save.
@@ -303,7 +303,7 @@ async def save_array(
303303
304304
Parameters
305305
----------
306-
store : Store or string
306+
store : Store or str
307307
Store or path to directory in file system or name of zip file.
308308
arr : ndarray
309309
NumPy array with data to save.
@@ -351,7 +351,7 @@ async def save_group(
351351
352352
Parameters
353353
----------
354-
store : Store or string
354+
store : Store or str
355355
Store or path to directory in file system or name of zip file.
356356
args : ndarray
357357
NumPy arrays with data to save.
@@ -467,7 +467,7 @@ async def group(
467467
468468
Parameters
469469
----------
470-
store : Store or string, optional
470+
store : Store or str, optional
471471
Store or path to directory in file system.
472472
overwrite : bool, optional
473473
If True, delete any pre-existing data in `store` at `path` before
@@ -481,7 +481,7 @@ async def group(
481481
to all attribute read operations.
482482
synchronizer : object, optional
483483
Array synchronizer.
484-
path : string, optional
484+
path : str, optional
485485
Group path within store.
486486
meta_array : array-like, optional
487487
An array instance to use for determining arrays to create and return
@@ -547,7 +547,7 @@ async def open_group(
547547
548548
Parameters
549549
----------
550-
store : Store, string, or mapping, optional
550+
store : Store, str, or mapping, optional
551551
Store or path to directory in file system or name of zip file.
552552
553553
Strings are interpreted as paths on the local file system
@@ -570,9 +570,9 @@ async def open_group(
570570
to all attribute read operations.
571571
synchronizer : object, optional
572572
Array synchronizer.
573-
path : string, optional
573+
path : str, optional
574574
Group path within store.
575-
chunk_store : Store or string, optional
575+
chunk_store : Store or str, optional
576576
Store or path to directory in file system or name of zip file.
577577
storage_options : dict
578578
If using an fsspec URL to create the store, these will be passed to
@@ -664,22 +664,22 @@ async def create(
664664
False, will be set to `shape`, i.e., single chunk for the whole array.
665665
If an int, the chunk size in each dimension will be given by the value
666666
of `chunks`. Default is True.
667-
dtype : string or dtype, optional
667+
dtype : str or dtype, optional
668668
NumPy dtype.
669669
compressor : Codec, optional
670670
Primary compressor.
671671
fill_value : object
672672
Default value to use for uninitialized portions of the array.
673673
order : {'C', 'F'}, optional
674674
Memory layout to be used within each chunk.
675-
store : Store or string
675+
store : Store or str
676676
Store or path to directory in file system or name of zip file.
677677
synchronizer : object, optional
678678
Array synchronizer.
679679
overwrite : bool, optional
680680
If True, delete all pre-existing data in `store` at `path` before
681681
creating the array.
682-
path : string, optional
682+
path : str, optional
683683
Path under which array is stored.
684684
chunk_store : MutableMapping, optional
685685
Separate storage for chunks. If not provided, `store` will be used
@@ -937,11 +937,11 @@ async def open_array(
937937
938938
Parameters
939939
----------
940-
store : Store or string
940+
store : Store or str
941941
Store or path to directory in file system or name of zip file.
942942
zarr_format : {2, 3, None}, optional
943943
The zarr format to use when saving.
944-
path : string, optional
944+
path : str, optional
945945
Path in store to array.
946946
storage_options : dict
947947
If using an fsspec URL to create the store, these will be passed to

src/zarr/core/array.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,11 +1288,11 @@ def get_basic_selection(
12881288
array. May be any combination of int and/or slice or ellipsis for multidimensional arrays.
12891289
out : NDBuffer, optional
12901290
If given, load the selected data directly into this buffer.
1291+
prototype : BufferPrototype, optional
1292+
The prototype of the buffer to use for the output data. If not provided, the default buffer prototype is used.
12911293
fields : str or sequence of str, optional
12921294
For arrays with a structured dtype, one or more fields can be specified to
12931295
extract data for.
1294-
prototype : BufferPrototype, optional
1295-
The prototype of the buffer to use for the output data. If not provided, the default buffer prototype is used.
12961296
12971297
Returns
12981298
-------
@@ -2284,6 +2284,17 @@ def resize(self, new_shape: ChunkCoords) -> Array:
22842284
This method does not modify the original Array object. Instead, it returns a new Array
22852285
with the specified shape.
22862286
2287+
Notes
2288+
-----
2289+
When resizing an array, the data are not rearranged in any way.
2290+
2291+
If one or more dimensions are shrunk, any chunks falling outside the
2292+
new array shape will be deleted from the underlying store.
2293+
However, it is noteworthy that the chunks partially falling inside the new array
2294+
(i.e. boundary chunks) will remain intact, and therefore,
2295+
the data falling outside the new array but inside the boundary chunks
2296+
would be restored by a subsequent resize operation that grows the array size.
2297+
22872298
Examples
22882299
--------
22892300
>>> import zarr
@@ -2301,17 +2312,6 @@ def resize(self, new_shape: ChunkCoords) -> Array:
23012312
(20000, 1000)
23022313
>>> z2.shape
23032314
(50, 50)
2304-
2305-
Notes
2306-
-----
2307-
When resizing an array, the data are not rearranged in any way.
2308-
2309-
If one or more dimensions are shrunk, any chunks falling outside the
2310-
new array shape will be deleted from the underlying store.
2311-
However, it is noteworthy that the chunks partially falling inside the new array
2312-
(i.e. boundary chunks) will remain intact, and therefore,
2313-
the data falling outside the new array but inside the boundary chunks
2314-
would be restored by a subsequent resize operation that grows the array size.
23152315
"""
23162316
return type(self)(
23172317
sync(

src/zarr/core/group.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ async def get(
299299
300300
Parameters
301301
----------
302-
key : string
302+
key : str
303303
Group member name.
304304
default : object
305305
Default value to return if key is not found (default: None).
@@ -396,7 +396,7 @@ async def require_group(self, name: str, overwrite: bool = False) -> AsyncGroup:
396396
397397
Parameters
398398
----------
399-
name : string
399+
name : str
400400
Group name.
401401
overwrite : bool, optional
402402
Overwrite any existing group with given `name` if present.
@@ -525,7 +525,7 @@ async def create_dataset(self, name: str, **kwargs: Any) -> AsyncArray:
525525
526526
Parameters
527527
----------
528-
name : string
528+
name : str
529529
Array name.
530530
kwargs : dict
531531
Additional arguments passed to :func:`zarr.AsyncGroup.create_array`.
@@ -558,11 +558,11 @@ async def require_dataset(
558558
559559
Parameters
560560
----------
561-
name : string
561+
name : str
562562
Array name.
563563
shape : int or tuple of ints
564564
Array shape.
565-
dtype : string or dtype, optional
565+
dtype : str or dtype, optional
566566
NumPy dtype.
567567
exact : bool, optional
568568
If True, require `dtype` to match exactly. If false, require
@@ -592,11 +592,11 @@ async def require_array(
592592
593593
Parameters
594594
----------
595-
name : string
595+
name : str
596596
Array name.
597597
shape : int or tuple of ints
598598
Array shape.
599-
dtype : string or dtype, optional
599+
dtype : str or dtype, optional
600600
NumPy dtype.
601601
exact : bool, optional
602602
If True, require `dtype` to match exactly. If false, require
@@ -857,7 +857,7 @@ def get(self, path: str, default: DefaultT | None = None) -> Array | Group | Def
857857
858858
Parameters
859859
----------
860-
key : string
860+
key : str
861861
Group member name.
862862
default : object
863863
Default value to return if key is not found (default: None).
@@ -1003,7 +1003,7 @@ def require_group(self, name: str, **kwargs: Any) -> Group:
10031003
10041004
Parameters
10051005
----------
1006-
name : string
1006+
name : str
10071007
Group name.
10081008
overwrite : bool, optional
10091009
Overwrite any existing group with given `name` if present.
@@ -1125,7 +1125,7 @@ def create_dataset(self, name: str, **kwargs: Any) -> Array:
11251125
11261126
Parameters
11271127
----------
1128-
name : string
1128+
name : str
11291129
Array name.
11301130
kwargs : dict
11311131
Additional arguments passed to :func:`zarr.Group.create_array`
@@ -1150,11 +1150,11 @@ def require_dataset(self, name: str, **kwargs: Any) -> Array:
11501150
11511151
Parameters
11521152
----------
1153-
name : string
1153+
name : str
11541154
Array name.
11551155
shape : int or tuple of ints
11561156
Array shape.
1157-
dtype : string or dtype, optional
1157+
dtype : str or dtype, optional
11581158
NumPy dtype.
11591159
exact : bool, optional
11601160
If True, require `dtype` to match exactly. If false, require
@@ -1177,11 +1177,11 @@ def require_array(self, name: str, **kwargs: Any) -> Array:
11771177
11781178
Parameters
11791179
----------
1180-
name : string
1180+
name : str
11811181
Array name.
11821182
shape : int or tuple of ints
11831183
Array shape.
1184-
dtype : string or dtype, optional
1184+
dtype : str or dtype, optional
11851185
NumPy dtype.
11861186
exact : bool, optional
11871187
If True, require `dtype` to match exactly. If false, require

src/zarr/storage/zip.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ class ZipStore(Store):
2222
2323
Parameters
2424
----------
25-
path : string
25+
path : str
2626
Location of file.
27-
compression : integer, optional
27+
mode : str, optional
28+
One of 'r' to read an existing file, 'w' to truncate and write a new
29+
file, 'a' to append to an existing file, or 'x' to exclusively create
30+
and write a new file.
31+
compression : int, optional
2832
Compression method to use when writing to the archive.
2933
allowZip64 : bool, optional
3034
If True (the default) will create ZIP files that use the ZIP64
3135
extensions when the zipfile is larger than 2 GiB. If False
3236
will raise an exception when the ZIP file would require ZIP64
3337
extensions.
34-
mode : string, optional
35-
One of 'r' to read an existing file, 'w' to truncate and write a new
36-
file, 'a' to append to an existing file, or 'x' to exclusively create
37-
and write a new file.
3838
"""
3939

4040
supports_writes: bool = True

0 commit comments

Comments
 (0)