Skip to content

Commit 390c435

Browse files
committed
improve docstring readability
1 parent 43307b3 commit 390c435

File tree

4 files changed

+70
-20
lines changed

4 files changed

+70
-20
lines changed

src/zarr/api/asynchronous.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,20 +835,25 @@ async def create(
835835
An iterable of Codec or dict serializations of Codecs. The elements of
836836
this collection specify the transformation from array values to stored bytes.
837837
V3 only. V2 arrays should use ``filters`` and ``compressor`` instead.
838+
838839
If no codecs are provided, default codecs will be used:
840+
839841
- For numeric arrays, the default is ``BytesCodec`` and ``ZstdCodec``.
840842
- For Unicode strings, the default is ``VLenUTF8Codec``.
841843
- For bytes or objects, the default is ``VLenBytesCodec``.
842-
These defaults can be changed using the ``array.v3_default_codecs`` variable in :mod:`zarr.core.config`.
844+
845+
These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`.
843846
compressor : Codec, optional
844847
Primary compressor to compress chunk data.
845848
V2 only. V3 arrays should use ``codecs`` instead.
849+
846850
If neither ``compressor`` nor ``filters`` are provided, a default compressor will be used:
851+
847852
- For numeric arrays, the default is ``ZstdCodec``.
848853
- For Unicode strings, the default is ``VLenUTF8Codec``.
849854
- For bytes or objects, the default is ``VLenBytesCodec``.
850-
These defaults can be changed using the ``array.v2_default_compressor`` variable in :mod:`zarr.core.config`.
851-
fill_value : object
855+
856+
These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`. fill_value : object
852857
Default value to use for uninitialized portions of the array.
853858
order : {'C', 'F'}, optional
854859
Memory layout to be used within each chunk.

src/zarr/core/array.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,14 @@ async def create(
420420
An iterable of Codec or dict serializations of Codecs. The elements of
421421
this collection specify the transformation from array values to stored bytes.
422422
V3 only. V2 arrays should use ``filters`` and ``compressor`` instead.
423+
423424
If no codecs are provided, default codecs will be used:
425+
424426
- For numeric arrays, the default is ``BytesCodec`` and ``ZstdCodec``.
425427
- For Unicode strings, the default is ``VLenUTF8Codec``.
426428
- For bytes or objects, the default is ``VLenBytesCodec``.
427-
These defaults can be changed using the ``array.v3_default_codecs`` variable in :mod:`zarr.core.config`.
429+
430+
These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`.
428431
dimension_names : Iterable[str], optional
429432
The names of the dimensions (default is None).
430433
V3 only. V2 arrays should not use this parameter.
@@ -445,11 +448,14 @@ async def create(
445448
compressor : dict[str, JSON], optional
446449
The compressor used to compress the data (default is None).
447450
V2 only. V3 arrays should use ``codecs`` instead.
451+
448452
If neither ``compressor`` nor ``filters`` are provided, a default compressor will be used:
453+
449454
- For numeric arrays, the default is ``ZstdCodec``.
450455
- For Unicode strings, the default is ``VLenUTF8Codec``.
451456
- For bytes or objects, the default is ``VLenBytesCodec``.
452-
These defaults can be changed using the ``array.v2_default_compressor`` variable in :mod:`zarr.core.config`.
457+
458+
These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`.
453459
overwrite : bool, optional
454460
Whether to raise an error if the store already exists (default is False).
455461
data : npt.ArrayLike, optional
@@ -1512,11 +1518,14 @@ def create(
15121518
An iterable of Codec or dict serializations of Codecs. The elements of
15131519
this collection specify the transformation from array values to stored bytes.
15141520
V3 only. V2 arrays should use ``filters`` and ``compressor`` instead.
1521+
15151522
If no codecs are provided, default codecs will be used:
1523+
15161524
- For numeric arrays, the default is ``BytesCodec`` and ``ZstdCodec``.
15171525
- For Unicode strings, the default is ``VLenUTF8Codec``.
15181526
- For bytes or objects, the default is ``VLenBytesCodec``.
1519-
These defaults can be changed using the ``array.v3_default_codecs`` variable in :mod:`zarr.core.config`.
1527+
1528+
These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`.
15201529
dimension_names : Iterable[str], optional
15211530
The names of the dimensions (default is None).
15221531
V3 only. V2 arrays should not use this parameter.
@@ -1537,11 +1546,14 @@ def create(
15371546
compressor : dict[str, JSON], optional
15381547
Primary compressor to compress chunk data.
15391548
V2 only. V3 arrays should use ``codecs`` instead.
1549+
15401550
If neither ``compressor`` nor ``filters`` are provided, a default compressor will be used:
1551+
15411552
- For numeric arrays, the default is ``ZstdCodec``.
15421553
- For Unicode strings, the default is ``VLenUTF8Codec``.
15431554
- For bytes or objects, the default is ``VLenBytesCodec``.
1544-
These defaults can be changed using the ``array.v2_default_compressor`` variable in :mod:`zarr.core.config`.
1555+
1556+
These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`.
15451557
overwrite : bool, optional
15461558
Whether to raise an error if the store already exists (default is False).
15471559

src/zarr/core/config.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
"""
2-
The config module is responsible for managing the configuration of zarr and is based on the Donfig python library.
2+
The config module is responsible for managing the configuration of zarr and is based on the Donfig python library.
33
For selecting custom implementations of codecs, pipelines, buffers and ndbuffers, first register the implementations
44
in the registry and then select them in the config.
5-
e.g. an implementation of the bytes codec in a class "your.module.NewBytesCodec", requires the value of codecs.bytes
6-
to be "your.module.NewBytesCodec".
7-
Donfig can be configured programmatically, by environment variables, or from YAML files in standard locations
8-
e.g. export ZARR_CODECS__BYTES="your.module.NewBytesCodec"
9-
(for more information see github.com/pytroll/donfig)
10-
Default values below point to the standard implementations of zarr-python
5+
6+
Example:
7+
An implementation of the bytes codec in a class `your.module.NewBytesCodec` requires the value of `codecs.bytes`
8+
to be `your.module.NewBytesCodec`.
9+
10+
```python
11+
from your.module import NewBytesCodec
12+
from zarr.core.config import register_codec, config
13+
14+
register_codec("bytes", NewBytesCodec)
15+
config.set({"codecs.bytes": "your.module.NewBytesCodec"})
16+
```
17+
18+
Donfig can be configured programmatically, by environment variables, or from YAML files in standard locations.
19+
For example, to set the bytes codec via an environment variable:
20+
21+
export ZARR_CODECS__BYTES="your.module.NewBytesCodec"
22+
23+
For more information, see the Donfig documentation at https://github.com/pytroll/donfig.
24+
25+
Default values below point to the standard implementations of zarr-python.
1126
"""
1227

1328
from __future__ import annotations

src/zarr/core/group.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,11 +1045,14 @@ async def create_array(
10451045
An iterable of Codec or dict serializations of Codecs. The elements of
10461046
this collection specify the transformation from array values to stored bytes.
10471047
V3 only. V2 arrays should use ``filters`` and ``compressor`` instead.
1048+
10481049
If no codecs are provided, default codecs will be used:
1050+
10491051
- For numeric arrays, the default is ``BytesCodec`` and ``ZstdCodec``.
10501052
- For Unicode strings, the default is ``VLenUTF8Codec``.
10511053
- For bytes or objects, the default is ``VLenBytesCodec``.
1052-
These defaults can be changed using the ``array.v3_default_codecs`` variable in :mod:`zarr.core.config`.
1054+
1055+
These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`.
10531056
dimension_names : Iterable[str] | None = None
10541057
The names of the dimensions of the array. V3 only.
10551058
chunks : ChunkCoords | None = None
@@ -1069,11 +1072,14 @@ async def create_array(
10691072
compressor : dict[str, JSON] | None = None
10701073
The compressor used to compress the data (default is None).
10711074
V2 only. V3 arrays should use ``codecs`` instead.
1075+
10721076
If neither ``compressor`` nor ``filters`` are provided, a default compressor will be used:
1077+
10731078
- For numeric arrays, the default is ``ZstdCodec``.
10741079
- For Unicode strings, the default is ``VLenUTF8Codec``.
10751080
- For bytes or objects, the default is ``VLenBytesCodec``.
1076-
These defaults can be changed using the ``array.v2_default_compressor`` variable in :mod:`zarr.core.config`.
1081+
1082+
These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`.
10771083
overwrite : bool = False
10781084
If True, a pre-existing array or group at the path of this array will
10791085
be overwritten. If False, the presence of a pre-existing array or group is
@@ -2266,11 +2272,14 @@ def create_array(
22662272
An iterable of Codec or dict serializations of Codecs. The elements of
22672273
this collection specify the transformation from array values to stored bytes.
22682274
V3 only. V2 arrays should use ``filters`` and ``compressor`` instead.
2275+
22692276
If no codecs are provided, default codecs will be used:
2277+
22702278
- For numeric arrays, the default is ``BytesCodec`` and ``ZstdCodec``.
22712279
- For Unicode strings, the default is ``VLenUTF8Codec``.
22722280
- For bytes or objects, the default is ``VLenBytesCodec``.
2273-
These defaults can be changed using the ``array.v3_default_codecs`` variable in :mod:`zarr.core.config`.
2281+
2282+
These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`.
22742283
dimension_names : Iterable[str] | None = None
22752284
The names of the dimensions of the array. V3 only.
22762285
chunks : ChunkCoords | None = None
@@ -2290,11 +2299,14 @@ def create_array(
22902299
compressor : dict[str, JSON] | None = None
22912300
The compressor used to compress the data (default is None).
22922301
V2 only. V3 arrays should use ``codecs`` instead.
2302+
22932303
If neither ``compressor`` nor ``filters`` are provided, a default compressor will be used:
2304+
22942305
- For numeric arrays, the default is ``ZstdCodec``.
22952306
- For Unicode strings, the default is ``VLenUTF8Codec``.
22962307
- For bytes or objects, the default is ``VLenBytesCodec``.
2297-
These defaults can be changed using the ``array.v2_default_compressor`` variable in :mod:`zarr.core.config`.
2308+
2309+
These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`.
22982310
overwrite : bool = False
22992311
If True, a pre-existing array or group at the path of this array will
23002312
be overwritten. If False, the presence of a pre-existing array or group is
@@ -2630,11 +2642,14 @@ def array(
26302642
An iterable of Codec or dict serializations of Codecs. The elements of
26312643
this collection specify the transformation from array values to stored bytes.
26322644
V3 only. V2 arrays should use ``filters`` and ``compressor`` instead.
2645+
26332646
If no codecs are provided, default codecs will be used:
2647+
26342648
- For numeric arrays, the default is ``BytesCodec`` and ``ZstdCodec``.
26352649
- For Unicode strings, the default is ``VLenUTF8Codec``.
26362650
- For bytes or objects, the default is ``VLenBytesCodec``.
2637-
These defaults can be changed using the ``array.v3_default_codecs`` variable in :mod:`zarr.core.config`.
2651+
2652+
These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`.
26382653
dimension_names : Iterable[str] | None = None
26392654
The names of the dimensions of the array. V3 only.
26402655
chunks : ChunkCoords | None = None
@@ -2654,11 +2669,14 @@ def array(
26542669
compressor : dict[str, JSON] | None = None
26552670
The compressor used to compress the data (default is None).
26562671
V2 only. V3 arrays should use ``codecs`` instead.
2672+
26572673
If neither ``compressor`` nor ``filters`` are provided, a default compressor will be used:
2674+
26582675
- For numeric arrays, the default is ``ZstdCodec``.
26592676
- For Unicode strings, the default is ``VLenUTF8Codec``.
26602677
- For bytes or objects, the default is ``VLenBytesCodec``.
2661-
These defaults can be changed using the ``array.v2_default_compressor`` variable in :mod:`zarr.core.config`.
2678+
2679+
These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`.
26622680
overwrite : bool = False
26632681
If True, a pre-existing array or group at the path of this array will
26642682
be overwritten. If False, the presence of a pre-existing array or group is

0 commit comments

Comments
 (0)