Skip to content

Commit b840c5c

Browse files
committed
make docs more consistent, and remove outdated references to configuration values that no longer work
1 parent 6a546d6 commit b840c5c

File tree

6 files changed

+274
-205
lines changed

6 files changed

+274
-205
lines changed

docs/user-guide/config.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Configuration options include the following:
2828

2929
- Default Zarr format ``default_zarr_version``
3030
- Default array order in memory ``array.order``
31-
- Default filters, serializers and compressors, e.g. ``array.v3_default_filters``, ``array.v3_default_serializer``, ``array.v3_default_compressors``, ``array.v2_default_filters`` and ``array.v2_default_compressor``
3231
- Whether empty chunks are written to storage ``array.write_empty_chunks``
3332
- Async and threading options, e.g. ``async.concurrency`` and ``threading.max_workers``
3433
- Selections of implementations of codecs, codec pipelines and buffers

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ test = [
7878
"pytest-accept",
7979
"rich",
8080
"mypy",
81+
'numpydoc',
8182
"hypothesis",
8283
"pytest-xdist",
8384
"packaging",

src/zarr/api/asynchronous.py

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ async def open(
328328
path : str or None, optional
329329
The path within the store to open.
330330
storage_options : dict
331-
If the store is backed by an fsspec-based implementation, then this dict will be passed to
332-
the Store constructor for that implementation. Ignored otherwise.
331+
If using an fsspec URL to create the store, these will be passed to
332+
the backend implementation. Ignored otherwise.
333333
**kwargs
334334
Additional parameters are passed through to :func:`zarr.creation.open_array` or
335335
:func:`zarr.hierarchy.open_group`.
@@ -440,7 +440,8 @@ async def save_array(
440440
arr : ndarray
441441
NumPy array with data to save.
442442
zarr_format : {2, 3, None}, optional
443-
The zarr format to use when saving (default is 3 if not specified).
443+
The zarr format to use when saving. The default is ``None``, which will
444+
use the default Zarr format defined in the global configuration object.
444445
path : str or None, optional
445446
The path within the store where the array will be saved.
446447
storage_options : dict
@@ -909,42 +910,20 @@ async def create(
909910
shape : int or tuple of ints
910911
Array shape.
911912
chunks : int or tuple of ints, optional
912-
The shape of the array's chunks.
913-
Zarr format 2 only. Zarr format 3 arrays should use `chunk_shape` instead.
914-
If not specified, default values are guessed based on the shape and dtype.
913+
Chunk shape. If True, will be guessed from `shape` and `dtype`. If
914+
False, will be set to `shape`, i.e., single chunk for the whole array.
915+
If an int, the chunk size in each dimension will be given by the value
916+
of `chunks`. Default is True.
915917
dtype : str or dtype, optional
916918
NumPy dtype.
917-
chunk_shape : int or tuple of ints, optional
918-
The shape of the Array's chunks (default is None).
919-
Zarr format 3 only. Zarr format 2 arrays should use `chunks` instead.
920-
chunk_key_encoding : ChunkKeyEncoding, optional
921-
A specification of how the chunk keys are represented in storage.
922-
Zarr format 3 only. Zarr format 2 arrays should use `dimension_separator` instead.
923-
Default is ``("default", "/")``.
924-
codecs : Sequence of Codecs or dicts, optional
925-
An iterable of Codec or dict serializations of Codecs. The elements of
926-
this collection specify the transformation from array values to stored bytes.
927-
Zarr format 3 only. Zarr format 2 arrays should use ``filters`` and ``compressor`` instead.
928-
929-
If no codecs are provided, default codecs will be used:
930-
931-
- For numeric arrays, the default is ``BytesCodec`` and ``ZstdCodec``.
932-
- For Unicode strings, the default is ``VLenUTF8Codec`` and ``ZstdCodec``.
933-
- For bytes or objects, the default is ``VLenBytesCodec`` and ``ZstdCodec``.
934-
935-
These defaults can be changed by modifying the value of ``array.v3_default_filters``,
936-
``array.v3_default_serializer`` and ``array.v3_default_compressors`` in :mod:`zarr.core.config`.
937919
compressor : Codec, optional
938920
Primary compressor to compress chunk data.
939921
Zarr format 2 only. Zarr format 3 arrays should use ``codecs`` instead.
940922
941-
If neither ``compressor`` nor ``filters`` are provided, a default compressor will be used:
942-
943-
- For numeric arrays, the default is ``ZstdCodec``.
944-
- For Unicode strings, the default is ``VLenUTF8Codec``.
945-
- For bytes or objects, the default is ``VLenBytesCodec``.
923+
If neither ``compressor`` nor ``filters`` are provided, the default compressor
924+
:class:`zarr.codecs.ZstdCodec`is used.
946925
947-
These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`.
926+
If ``compressor`` is set to ``None``, no compression is used.
948927
fill_value : object
949928
Default value to use for uninitialized portions of the array.
950929
order : {'C', 'F'}, optional
@@ -964,10 +943,25 @@ async def create(
964943
chunk_store : MutableMapping, optional
965944
Separate storage for chunks. If not provided, `store` will be used
966945
for storage of both chunks and metadata.
967-
filters : sequence of Codecs, optional
968-
Sequence of filters to use to encode chunk data prior to compression.
969-
Zarr format 2 only. If no ``filters`` are provided, a default set of filters will be used.
970-
These defaults can be changed by modifying the value of ``array.v2_default_filters`` in :mod:`zarr.core.config`.
946+
filters : Iterable[Codec] | Literal["auto"], optional
947+
Iterable of filters to apply to each chunk of the array, in order, before serializing that
948+
chunk to bytes.
949+
950+
For Zarr format 3, a "filter" is a codec that takes an array and returns an array,
951+
and these values must be instances of :class:`zarr.abc.codec.ArrayArrayCodec`, or a
952+
dict representations of :class:`zarr.abc.codec.ArrayArrayCodec`.
953+
954+
For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the
955+
the order if your filters is consistent with the behavior of each filter.
956+
957+
The default value of ``"auto"`` instructs Zarr to use a default used based on the data
958+
type of the array and the Zarr format specified. For all data types in Zarr V3, and most
959+
data types in Zarr V2, the default filters are empty. The only cases where default filters
960+
are not empty is when the Zarr format is 2, and the data type is a variable-length data type like
961+
`:class:zarr.dtype.VariableLengthUTF8` or `:class:zarr.dtype.VariableLengthUTF8`. In these cases,
962+
the default filters contains a single element which is a codec specific to that particular data type.
963+
964+
To create an array with no filters, provide an empty iterable or the value ``None``.
971965
cache_metadata : bool, optional
972966
If True, array configuration metadata will be cached for the
973967
lifetime of the object. If False, array metadata will be reloaded
@@ -984,7 +978,6 @@ async def create(
984978
dimension_separator : {'.', '/'}, optional
985979
Separator placed between the dimensions of a chunk.
986980
Zarr format 2 only. Zarr format 3 arrays should use ``chunk_key_encoding`` instead.
987-
Default is ".".
988981
write_empty_chunks : bool, optional
989982
Deprecated in favor of the ``config`` keyword argument.
990983
Pass ``{'write_empty_chunks': <value>}`` to ``create`` instead of using this parameter.
@@ -994,15 +987,36 @@ async def create(
994987
that chunk is not be stored, and the store entry for that chunk's key
995988
is deleted.
996989
zarr_format : {2, 3, None}, optional
997-
The zarr format to use when saving.
998-
Default is 3.
990+
The Zarr format to use when creating an array. The default is ``None``,
991+
which instructs Zarr to choose the default Zarr format value defined in the
992+
runtime configuration.
999993
meta_array : array-like, optional
1000-
An array instance to use for determining arrays to create and return
1001-
to users. Use `numpy.empty(())` by default.
994+
Not implemented.
995+
attributes : dict[str, JSON], optional
996+
A dictionary of user attributes to store with the array.
997+
chunk_shape : int or tuple of ints, optional
998+
The shape of the Array's chunks (default is None).
999+
Zarr format 3 only. Zarr format 2 arrays should use `chunks` instead.
1000+
chunk_key_encoding : ChunkKeyEncoding, optional
1001+
A specification of how the chunk keys are represented in storage.
1002+
Zarr format 3 only. Zarr format 2 arrays should use `dimension_separator` instead.
1003+
Default is ``("default", "/")``.
1004+
codecs : Sequence of Codecs or dicts, optional
1005+
An iterable of Codec or dict serializations of Codecs. Zarr V3 only.
1006+
1007+
The elements of ``codecs`` specify the transformation from array values to stored bytes.
1008+
Zarr format 3 only. Zarr format 2 arrays should use ``filters`` and ``compressor`` instead.
1009+
1010+
If no codecs are provided, default codecs will be used based on the data type of the array.
1011+
For most data types, the default codecs are the tuple ``(BytesCodec(), ZstdCodec())``;
1012+
data types that require a special :class:`zarr.abc.codec.ArrayBytesCodec`, like variable-length strings or bytes,
1013+
will use the :class:`zarr.abc.codec.ArrayBytesCodec` required for the data type instead of :class:`zarr.codecs.BytesCodec`.
1014+
dimension_names : Iterable[str | None] | None = None
1015+
An iterable of dimension names. Zarr format 3 only.
10021016
storage_options : dict
10031017
If using an fsspec URL to create the store, these will be passed to
10041018
the backend implementation. Ignored otherwise.
1005-
config : ArrayConfig or ArrayConfigLike, optional
1019+
config : ArrayConfig | ArrayConfigLike, optional
10061020
Runtime configuration of the array. If provided, will override the
10071021
default values from `zarr.config.array`.
10081022

0 commit comments

Comments
 (0)