Skip to content

Commit 58406c8

Browse files
committed
add docstrings to create in asynchronous.py and array.py
1 parent 00e241e commit 58406c8

File tree

2 files changed

+94
-30
lines changed

2 files changed

+94
-30
lines changed

src/zarr/api/asynchronous.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ async def save_array(
394394
arr : ndarray
395395
NumPy array with data to save.
396396
zarr_format : {2, 3, None}, optional
397-
The zarr format to use when saving.
397+
The zarr format to use when saving (default is 3).
398398
path : str or None, optional
399399
The path within the store where the array will be saved.
400400
storage_options : dict
@@ -810,24 +810,40 @@ async def create(
810810
shape : int or tuple of ints
811811
Array shape.
812812
chunks : int or tuple of ints, optional
813-
Chunk shape. If True, will be guessed from `shape` and `dtype`. If
814-
False, will be set to `shape`, i.e., single chunk for the whole array.
815-
If an int, the chunk size in each dimension will be given by the value
816-
of `chunks`. Default is True.
813+
The shape of the array's chunks.
814+
V2 only. V3 arrays should use `chunk_shape` instead.
815+
Default values are guessed based on the shape and dtype.
817816
dtype : str or dtype, optional
818817
NumPy dtype.
818+
chunk_shape : int or tuple of ints, optional
819+
The shape of the Array's chunks (default is None).
820+
V3 only. V2 arrays should use `chunks` instead.
821+
chunk_key_encoding : ChunkKeyEncoding, optional
822+
A specification of how the chunk keys are represented in storage.
823+
V3 only. V2 arrays should use `dimension_separator` instead.
824+
Default is ("default", "/").
825+
codecs : Sequence of Codecs or dicts, optional
826+
An iterable of Codec or dict serializations thereof. The elements of
827+
this collection specify the transformation from array values to stored bytes.
828+
V3 only. V2 arrays should use `filters` and `compressor` instead.
829+
If no codecs are provided, default codecs will be used:
830+
- For numeric arrays, the default is `BytesCodec` and `ZstdCodec`.
831+
- For Unicode strings, the default is `VLenUTF8Codec`.
832+
- For bytes or objects, the default is `VLenBytesCodec`.
833+
These defaults can be changed using the `array.v3_default_codecs` variable in the Zarr config.
819834
compressor : Codec, optional
820-
Primary compressor for `zarr_format=2`.
835+
Primary compressor to compress chunk data.
836+
V2 only. V3 arrays should use `codecs` instead.
821837
If neither `compressor` nor `filters` are provided, a default compressor will be used:
822838
- For numeric arrays, the default is `ZstdCodec`.
823839
- For Unicode strings, the default is `VLenUTF8Codec`.
824840
- For bytes or objects, the default is `VLenBytesCodec`.
825-
These defaults can be changed using the `v2_default_compressor` variable in the Zarr config.
841+
These defaults can be changed using the `array.v2_default_compressor` variable in the Zarr config.
826842
fill_value : object
827843
Default value to use for uninitialized portions of the array.
828844
order : {'C', 'F'}, optional
829845
Memory layout to be used within each chunk.
830-
Default is set in Zarr's config (`array.order`).
846+
Default is specified in the Zarr config `array.order`.
831847
store : Store or str
832848
Store or path to directory in file system or name of zip file.
833849
synchronizer : object, optional
@@ -842,6 +858,8 @@ async def create(
842858
for storage of both chunks and metadata.
843859
filters : sequence of Codecs, optional
844860
Sequence of filters to use to encode chunk data prior to compression.
861+
V2 only. If neither `compressor` nor `filters` are provided, a default
862+
compressor will be used. (see `compressor` for details)
845863
cache_metadata : bool, optional
846864
If True, array configuration metadata will be cached for the
847865
lifetime of the object. If False, array metadata will be reloaded
@@ -857,7 +875,8 @@ async def create(
857875
A codec to encode object arrays, only needed if dtype=object.
858876
dimension_separator : {'.', '/'}, optional
859877
Separator placed between the dimensions of a chunk.
860-
878+
V2 only. V3 arrays should use `chunk_key_encoding` instead.
879+
Default is ".".
861880
.. versionadded:: 2.8
862881
863882
write_empty_chunks : bool, optional
@@ -873,6 +892,7 @@ async def create(
873892
874893
zarr_format : {2, 3, None}, optional
875894
The zarr format to use when saving.
895+
Default is 3.
876896
meta_array : array-like, optional
877897
An array instance to use for determining arrays to create and return
878898
to users. Use `numpy.empty(())` by default.

src/zarr/core/array.py

Lines changed: 65 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -408,27 +408,47 @@ async def create(
408408
attributes : dict[str, JSON], optional
409409
The attributes of the array (default is None).
410410
chunk_shape : ChunkCoords, optional
411-
The shape of the array's chunks (default is None).
411+
The shape of the array's chunks
412+
V3 only. V2 arrays should use `chunks` instead.
413+
Default values are guessed based on the shape and dtype.
412414
chunk_key_encoding : ChunkKeyEncoding, optional
413-
The chunk key encoding (default is None).
414-
codecs : Iterable[Codec | dict[str, JSON]], optional
415-
The codecs used to encode the data (default is None).
415+
A specification of how the chunk keys are represented in storage.
416+
V3 only. V2 arrays should use `dimension_separator` instead.
417+
Default is ("default", "/").
418+
codecs : Sequence of Codecs or dicts, optional
419+
An iterable of Codec or dict serializations thereof. The elements of
420+
this collection specify the transformation from array values to stored bytes.
421+
V3 only. V2 arrays should use `filters` and `compressor` instead.
422+
If no codecs are provided, default codecs will be used:
423+
- For numeric arrays, the default is `BytesCodec` and `ZstdCodec`.
424+
- For Unicode strings, the default is `VLenUTF8Codec`.
425+
- For bytes or objects, the default is `VLenBytesCodec`.
426+
These defaults can be changed using the `array.v3_default_codecs` variable in the Zarr config.
416427
dimension_names : Iterable[str], optional
417428
The names of the dimensions (default is None).
429+
V3 only. V2 arrays should not use this parameter.
418430
chunks : ShapeLike, optional
419-
The shape of the array's chunks (default is None).
420-
V2 only. V3 arrays should not have 'chunks' parameter.
431+
The shape of the array's chunks.
432+
V2 only. V3 arrays should use `chunk_shape` instead.
433+
Default values are guessed based on the shape and dtype.
421434
dimension_separator : Literal[".", "/"], optional
422-
The dimension separator (default is None).
423-
V2 only. V3 arrays cannot have a dimension separator.
435+
The dimension separator (default is ".").
436+
V2 only. V3 arrays should use `chunk_key_encoding` instead.
424437
order : Literal["C", "F"], optional
425-
The order of the array (default is None).
438+
The order of the array (default is specified in the Zarr config `array.order`).
426439
filters : list[dict[str, JSON]], optional
427-
The filters used to compress the data (default is None).
428-
V2 only. V3 arrays should not have 'filters' parameter.
440+
Sequence of filters to use to encode chunk data prior to compression.
441+
V2 only. V3 arrays should use `codecs` instead. If neither `compressor`
442+
nor `filters` are provided, a default compressor will be used. (see
443+
`compressor` for details)
429444
compressor : dict[str, JSON], optional
430445
The compressor used to compress the data (default is None).
431-
V2 only. V3 arrays should not have 'compressor' parameter.
446+
V2 only. V3 arrays should use `codecs` instead.
447+
If neither `compressor` nor `filters` are provided, a default compressor will be used:
448+
- For numeric arrays, the default is `ZstdCodec`.
449+
- For Unicode strings, the default is `VLenUTF8Codec`.
450+
- For bytes or objects, the default is `VLenBytesCodec`.
451+
These defaults can be changed using the `array.v2_default_compressor` variable in the Zarr config.
432452
overwrite : bool, optional
433453
Whether to raise an error if the store already exists (default is False).
434454
data : npt.ArrayLike, optional
@@ -1472,23 +1492,47 @@ def create(
14721492
dtype : npt.DTypeLike
14731493
The data type of the array.
14741494
chunk_shape : ChunkCoords, optional
1475-
The shape of the Array's chunks (default is None).
1495+
The shape of the Array's chunks.
1496+
V3 only. V2 arrays should use `chunks` instead.
1497+
Default values are guessed based on the shape and dtype.
14761498
chunk_key_encoding : ChunkKeyEncoding, optional
1477-
The chunk key encoding (default is None).
1478-
codecs : Iterable[Codec | dict[str, JSON]], optional
1479-
The codecs used to encode the data (default is None).
1499+
A specification of how the chunk keys are represented in storage.
1500+
V3 only. V2 arrays should use `dimension_separator` instead.
1501+
Default is ("default", "/").
1502+
codecs : Sequence of Codecs or dicts, optional
1503+
An iterable of Codec or dict serializations thereof. The elements of
1504+
this collection specify the transformation from array values to stored bytes.
1505+
V3 only. V2 arrays should use `filters` and `compressor` instead.
1506+
If no codecs are provided, default codecs will be used:
1507+
- For numeric arrays, the default is `BytesCodec` and `ZstdCodec`.
1508+
- For Unicode strings, the default is `VLenUTF8Codec`.
1509+
- For bytes or objects, the default is `VLenBytesCodec`.
1510+
These defaults can be changed using the `array.v3_default_codecs` variable in the Zarr config.
14801511
dimension_names : Iterable[str], optional
14811512
The names of the dimensions (default is None).
1513+
V3 only. V2 arrays should not use this parameter.
14821514
chunks : ChunkCoords, optional
1483-
The shape of the Array's chunks (default is None).
1515+
The shape of the array's chunks.
1516+
V2 only. V3 arrays should use `chunk_shape` instead.
1517+
Default values are guessed based on the shape and dtype.
14841518
dimension_separator : Literal[".", "/"], optional
1485-
The dimension separator (default is None).
1519+
The dimension separator (default is ".").
1520+
V2 only. V3 arrays should use `chunk_key_encoding` instead.
14861521
order : Literal["C", "F"], optional
1487-
The order of the array (default is None).
1522+
The order of the array (default is specified in the Zarr config `array.order`).
14881523
filters : list[dict[str, JSON]], optional
1489-
The filters used to compress the data (default is None).
1524+
Sequence of filters to use to encode chunk data prior to compression.
1525+
V2 only. V3 arrays should use `codecs` instead. If neither `compressor`
1526+
nor `filters` are provided, a default compressor will be used. (see
1527+
`compressor` for details)
14901528
compressor : dict[str, JSON], optional
1491-
The compressor used to compress the data (default is None).
1529+
Primary compressor to compress chunk data.
1530+
V2 only. V3 arrays should use `codecs` instead.
1531+
If neither `compressor` nor `filters` are provided, a default compressor will be used:
1532+
- For numeric arrays, the default is `ZstdCodec`.
1533+
- For Unicode strings, the default is `VLenUTF8Codec`.
1534+
- For bytes or objects, the default is `VLenBytesCodec`.
1535+
These defaults can be changed using the `array.v2_default_compressor` variable in the Zarr config.
14921536
overwrite : bool, optional
14931537
Whether to raise an error if the store already exists (default is False).
14941538

0 commit comments

Comments
 (0)