Skip to content

Add some more numpydoc rules/associated fixes #2399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,15 @@ ignore = [

[tool.numpydoc_validation]
# See https://numpydoc.readthedocs.io/en/latest/validation.html#built-in-validation-checks for list of checks
checks = ["GL06", "GL07", "GL10", "PR03", "PR05", "PR06"]
checks = [
"GL06",
"GL07",
"GL09",
"GL10",
"SS02",
"SS04",
"PR02",
"PR03",
"PR05",
"PR06",
]
20 changes: 10 additions & 10 deletions src/zarr/abc/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:

Parameters
----------
chunk_spec : ArraySpec
array_spec : ArraySpec

Returns
-------
Expand All @@ -99,11 +99,11 @@ def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: Chun

Parameters
----------
shape: ChunkCoords
shape : ChunkCoords
The array shape
dtype: np.dtype[Any]
dtype : np.dtype[Any]
The array data type
chunk_grid: ChunkGrid
chunk_grid : ChunkGrid
The array chunk grid
"""
...
Expand Down Expand Up @@ -292,11 +292,11 @@ def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: Chun

Parameters
----------
shape: ChunkCoords
shape : ChunkCoords
The array shape
dtype: np.dtype[Any]
dtype : np.dtype[Any]
The array data type
chunk_grid: ChunkGrid
chunk_grid : ChunkGrid
The array chunk grid
"""
...
Expand All @@ -308,7 +308,7 @@ def compute_encoded_size(self, byte_length: int, array_spec: ArraySpec) -> int:

Parameters
----------
input_byte_length : int
byte_length : int
array_spec : ArraySpec

Returns
Expand All @@ -327,7 +327,7 @@ async def decode(

Parameters
----------
chunks_and_specs : Iterable[tuple[Buffer | None, ArraySpec]]
chunk_bytes_and_specs : Iterable[tuple[Buffer | None, ArraySpec]]
Ordered set of encoded chunks with their accompanying chunk spec.

Returns
Expand All @@ -346,7 +346,7 @@ async def encode(

Parameters
----------
chunks_and_specs : Iterable[tuple[NDBuffer | None, ArraySpec]]
chunk_arrays_and_specs : Iterable[tuple[NDBuffer | None, ArraySpec]]
Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/abc/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def with_mode(self, mode: AccessModeLiteral) -> Self:

Parameters
----------
mode: AccessModeLiteral
mode : AccessModeLiteral
The new mode to use.

Returns
Expand Down
24 changes: 12 additions & 12 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@


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

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


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

new = kwargs.copy()

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


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


Expand All @@ -152,9 +152,9 @@ async def consolidate_metadata(

Parameters
----------
store: StoreLike
store : StoreLike
The store-like object whose metadata you wish to consolidate.
path: str, optional
path : str, optional
A path to a group in the store to consolidate at. Only children
below that group will be consolidated.

Expand Down Expand Up @@ -341,13 +341,13 @@ async def save(
----------
store : Store or str
Store or path to directory in file system or name of zip file.
args : ndarray
*args : ndarray
NumPy arrays with data to save.
zarr_format : {2, 3, None}, optional
The zarr format to use when saving.
path : str or None, optional
The path within the group where the arrays will be saved.
kwargs
**kwargs
NumPy arrays with data to save.
"""
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
Expand Down Expand Up @@ -386,7 +386,7 @@ async def save_array(
storage_options : dict
If using an fsspec URL to create the store, these will be passed to
the backend implementation. Ignored otherwise.
kwargs
**kwargs
Passed through to :func:`create`, e.g., compressor.
"""
zarr_format = (
Expand Down Expand Up @@ -423,7 +423,7 @@ async def save_group(
----------
store : Store or str
Store or path to directory in file system or name of zip file.
args : ndarray
*args : ndarray
NumPy arrays with data to save.
zarr_format : {2, 3, None}, optional
The zarr format to use when saving.
Expand All @@ -432,7 +432,7 @@ async def save_group(
storage_options : dict
If using an fsspec URL to create the store, these will be passed to
the backend implementation. Ignored otherwise.
kwargs
**kwargs
NumPy arrays with data to save.
"""
zarr_format = (
Expand Down Expand Up @@ -479,7 +479,7 @@ async def array(
----------
data : array_like
The data to fill the array with.
kwargs
**kwargs
Passed through to :func:`create`.

Returns
Expand Down
42 changes: 15 additions & 27 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ class AsyncArray(Generic[T_ArrayMetadata]):
The metadata of the array.
store_path : StorePath
The path to the Zarr store.
codec_pipeline : CodecPipeline, optional
The codec pipeline used for encoding and decoding chunks, by default None.
order : {'C', 'F'}, optional
The order of the array data in memory, by default None.

Expand Down Expand Up @@ -857,9 +855,9 @@ def _iter_chunk_coords(

Parameters
----------
origin: Sequence[int] | None, default=None
origin : Sequence[int] | None, default=None
The origin of the selection relative to the array's chunk grid.
selection_shape: Sequence[int] | None, default=None
selection_shape : Sequence[int] | None, default=None
The shape of the selection in chunk grid coordinates.

Yields
Expand All @@ -878,9 +876,9 @@ def _iter_chunk_keys(

Parameters
----------
origin: Sequence[int] | None, default=None
origin : Sequence[int] | None, default=None
The origin of the selection relative to the array's chunk grid.
selection_shape: Sequence[int] | None, default=None
selection_shape : Sequence[int] | None, default=None
The shape of the selection in chunk grid coordinates.

Yields
Expand All @@ -901,9 +899,9 @@ def _iter_chunk_regions(

Parameters
----------
origin: Sequence[int] | None, default=None
origin : Sequence[int] | None, default=None
The origin of the selection relative to the array's chunk grid.
selection_shape: Sequence[int] | None, default=None
selection_shape : Sequence[int] | None, default=None
The shape of the selection in chunk grid coordinates.

Yields
Expand Down Expand Up @@ -1151,17 +1149,7 @@ async def info(self) -> None:

@dataclass(frozen=True)
class Array:
"""Instantiate an array from an initialized store.

Parameters
----------
store : StoreLike
The array store that has already been initialized.
shape : ChunkCoords
The shape of the array.
dtype : npt.DTypeLike
The dtype of the array.
"""
"""Instantiate an array from an initialized store."""

_async_array: AsyncArray[ArrayV3Metadata] | AsyncArray[ArrayV2Metadata]

Expand Down Expand Up @@ -1419,9 +1407,9 @@ def _iter_chunk_coords(

Parameters
----------
origin: Sequence[int] | None, default=None
origin : Sequence[int] | None, default=None
The origin of the selection relative to the array's chunk grid.
selection_shape: Sequence[int] | None, default=None
selection_shape : Sequence[int] | None, default=None
The shape of the selection in chunk grid coordinates.

Yields
Expand Down Expand Up @@ -1456,9 +1444,9 @@ def _iter_chunk_keys(

Parameters
----------
origin: Sequence[int] | None, default=None
origin : Sequence[int] | None, default=None
The origin of the selection relative to the array's chunk grid.
selection_shape: Sequence[int] | None, default=None
selection_shape : Sequence[int] | None, default=None
The shape of the selection in chunk grid coordinates.

Yields
Expand All @@ -1478,9 +1466,9 @@ def _iter_chunk_regions(

Parameters
----------
origin: Sequence[int] | None, default=None
origin : Sequence[int] | None, default=None
The origin of the selection relative to the array's chunk grid.
selection_shape: Sequence[int] | None, default=None
selection_shape : Sequence[int] | None, default=None
The shape of the selection in chunk grid coordinates.

Yields
Expand Down Expand Up @@ -2231,7 +2219,7 @@ def get_mask_selection(

Parameters
----------
selection : ndarray, bool
mask : ndarray, bool
A Boolean array of the same shape as the array against which the selection is
being made.
out : NDBuffer, optional
Expand Down Expand Up @@ -2314,7 +2302,7 @@ def set_mask_selection(

Parameters
----------
selection : ndarray, bool
mask : ndarray, bool
A Boolean array of the same shape as the array against which the selection is
being made.
value : npt.ArrayLike
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/buffer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class NDBuffer:

Parameters
----------
ndarray_like
array : ndarray_like
ndarray-like object that is convertible to a regular Numpy array.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/buffer/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class NDBuffer(core.NDBuffer):

Parameters
----------
ndarray_like
array
ndarray-like object that is convertible to a regular Numpy array.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/buffer/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class NDBuffer(core.NDBuffer):

Parameters
----------
ndarray_like
array
ndarray-like object that is convertible to a regular Numpy array.
"""

Expand Down
10 changes: 5 additions & 5 deletions src/zarr/core/chunk_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def _guess_chunks(

Parameters
----------
shape: ChunkCoords
shape : ChunkCoords
The chunk shape.
typesize: int
typesize : int
The size, in bytes, of each element of the chunk.
increment_bytes: int = 256 * 1024
increment_bytes : int = 256 * 1024
The number of bytes used to increment or decrement the target chunk size in bytes.
min_bytes: int = 128 * 1024
min_bytes : int = 128 * 1024
The soft lower bound on the final chunk size in bytes.
max_bytes: int = 64 * 1024 * 1024
max_bytes : int = 64 * 1024 * 1024
The hard upper bound on the final chunk size in bytes.

Returns
Expand Down
Loading