From 94cce29d70139b2493c47ce69e480ab013921965 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Sat, 4 Jan 2025 15:07:55 +0100 Subject: [PATCH 1/4] Consistent use of 'Zarr format 2 or 3' instead of v2 and v3 in docs and messages --- docs/index.rst | 2 +- docs/user-guide/extending.rst | 6 +- docs/user-guide/v3_migration.rst | 2 +- pyproject.toml | 2 +- src/zarr/api/asynchronous.py | 22 +++--- src/zarr/api/synchronous.py | 38 +++++------ src/zarr/codecs/vlen_utf8.py | 4 +- src/zarr/core/array.py | 112 +++++++++++++++---------------- src/zarr/core/common.py | 2 +- src/zarr/core/group.py | 106 ++++++++++++++--------------- src/zarr/core/metadata/v2.py | 6 +- src/zarr/core/metadata/v3.py | 6 +- tests/test_array.py | 2 +- tests/test_metadata/test_v3.py | 4 +- 14 files changed, 157 insertions(+), 157 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 29baf4b94a..eb9fcea781 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -25,7 +25,7 @@ Zarr-Python Zarr-Python is a Python library for reading and writing Zarr groups and arrays. Highlights include: -* Specification support for both Zarr v2 and v3. +* Specification support for both Zarr format 2 and 3. * Create and read from N-dimensional arrays using NumPy-like semantics. * Flexible storage enables reading and writing from local, cloud and in-memory stores. * High performance: Enables fast I/O with support for asynchronous I/O and multi-threading. diff --git a/docs/user-guide/extending.rst b/docs/user-guide/extending.rst index 405dcb92c0..08ce257387 100644 --- a/docs/user-guide/extending.rst +++ b/docs/user-guide/extending.rst @@ -10,8 +10,8 @@ Custom codecs ------------- .. note:: - This section explains how custom codecs can be created for Zarr version 3 data. For Zarr - version 2, codecs should subclass the + This section explains how custom codecs can be created for Zarr format 3 data. For Zarr + format 2, codecs should subclass the `numcodecs.abc.Codec `_ base class and register through `numcodecs.registry.register_codec `_. @@ -66,7 +66,7 @@ strongly recommended to prefix the codec identifier with a unique name. For exam the codecs from ``numcodecs`` are prefixed with ``numcodecs.``, e.g. ``numcodecs.delta``. .. note:: - Note that the extension mechanism for the Zarr version 3 is still under development. + Note that the extension mechanism for the Zarr format 3 is still under development. Requirements for custom codecs including the choice of codec identifiers might change in the future. diff --git a/docs/user-guide/v3_migration.rst b/docs/user-guide/v3_migration.rst index fffe50e5e1..3e2b5f1e84 100644 --- a/docs/user-guide/v3_migration.rst +++ b/docs/user-guide/v3_migration.rst @@ -4,7 +4,7 @@ Zarr-Python 3 represents a major refactor of the Zarr-Python codebase. Some of the goals motivating this refactor included: -* adding support for the Zarr V3 specification (along with the Zarr V2 specification) +* adding support for the Zarr format 3 specification (along with the Zarr format 2 specification) * cleaning up internal and user facing APIs * improving performance (particularly in high latency storage environments like cloud object stores) diff --git a/pyproject.toml b/pyproject.toml index aaedc09736..b33786749e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -380,7 +380,7 @@ filterwarnings = [ "ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning", "ignore:Creating a zarr.buffer.gpu.*:UserWarning", "ignore:Duplicate name:UserWarning", # from ZipFile - "ignore:.*is currently not part in the Zarr version 3 specification.*:UserWarning", + "ignore:.*is currently not part in the Zarr format 3 specification.*:UserWarning", ] markers = [ "gpu: mark a test as requiring CuPy and GPU" diff --git a/src/zarr/api/asynchronous.py b/src/zarr/api/asynchronous.py index f54a824088..fe18cdabcd 100644 --- a/src/zarr/api/asynchronous.py +++ b/src/zarr/api/asynchronous.py @@ -198,7 +198,7 @@ async def consolidate_metadata( if any(m.zarr_format == 3 for m in members_metadata.values()): warnings.warn( - "Consolidated metadata is currently not part in the Zarr version 3 specification. It " + "Consolidated metadata is currently not part in the Zarr format 3 specification. It " "may not be supported by other zarr implementations and may change in the future.", category=UserWarning, stacklevel=1, @@ -770,8 +770,8 @@ async def open_group( Whether to use consolidated metadata. By default, consolidated metadata is used if it's present in the - store (in the ``zarr.json`` for Zarr v3 and in the ``.zmetadata`` file - for Zarr v2). + store (in the ``zarr.json`` for Zarr format 3 and in the ``.zmetadata`` file + for Zarr format 2). To explicitly require consolidated metadata, set ``use_consolidated=True``, which will raise an exception if consolidated metadata is not found. @@ -779,7 +779,7 @@ async def open_group( To explicitly *not* use consolidated metadata, set ``use_consolidated=False``, which will fall back to using the regular, non consolidated metadata. - Zarr v2 allowed configuring the key storing the consolidated metadata + Zarr format 2 allowed configuring the key storing the consolidated metadata (``.zmetadata`` by default). Specify the custom key as ``use_consolidated`` to load consolidated metadata from a non-default key. @@ -870,21 +870,21 @@ async def create( Array shape. chunks : int or tuple of ints, optional The shape of the array's chunks. - V2 only. V3 arrays should use `chunk_shape` instead. + Zarr format 2 only. Zarr format 3 arrays should use `chunk_shape` instead. If not specified, default values are guessed based on the shape and dtype. dtype : str or dtype, optional NumPy dtype. chunk_shape : int or tuple of ints, optional The shape of the Array's chunks (default is None). - V3 only. V2 arrays should use `chunks` instead. + Zarr format 3 only. Zarr format 2 arrays should use `chunks` instead. chunk_key_encoding : ChunkKeyEncoding, optional A specification of how the chunk keys are represented in storage. - V3 only. V2 arrays should use `dimension_separator` instead. + Zarr format 3 only. Zarr format 2 arrays should use `dimension_separator` instead. Default is ``("default", "/")``. codecs : Sequence of Codecs or dicts, optional An iterable of Codec or dict serializations of Codecs. The elements of this collection specify the transformation from array values to stored bytes. - V3 only. V2 arrays should use ``filters`` and ``compressor`` instead. + Zarr format 3 only. Zarr format 2 arrays should use ``filters`` and ``compressor`` instead. If no codecs are provided, default codecs will be used: @@ -895,7 +895,7 @@ async def create( These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. compressor : Codec, optional Primary compressor to compress chunk data. - V2 only. V3 arrays should use ``codecs`` instead. + Zarr format 2 only. Zarr format 3 arrays should use ``codecs`` instead. If neither ``compressor`` nor ``filters`` are provided, a default compressor will be used: @@ -925,7 +925,7 @@ async def create( for storage of both chunks and metadata. filters : sequence of Codecs, optional Sequence of filters to use to encode chunk data prior to compression. - V2 only. If no ``filters`` are provided, a default set of filters will be used. + Zarr format 2 only. If no ``filters`` are provided, a default set of filters will be used. These defaults can be changed by modifying the value of ``array.v2_default_filters`` in :mod:`zarr.core.config`. cache_metadata : bool, optional If True, array configuration metadata will be cached for the @@ -942,7 +942,7 @@ async def create( A codec to encode object arrays, only needed if dtype=object. dimension_separator : {'.', '/'}, optional Separator placed between the dimensions of a chunk. - V2 only. V3 arrays should use ``chunk_key_encoding`` instead. + Zarr format 2 only. Zarr format 3 arrays should use ``chunk_key_encoding`` instead. Default is ".". write_empty_chunks : bool, optional Deprecated in favor of the ``config`` keyword argument. diff --git a/src/zarr/api/synchronous.py b/src/zarr/api/synchronous.py index e4a842ef8f..174e2390a6 100644 --- a/src/zarr/api/synchronous.py +++ b/src/zarr/api/synchronous.py @@ -502,8 +502,8 @@ def open_group( Whether to use consolidated metadata. By default, consolidated metadata is used if it's present in the - store (in the ``zarr.json`` for Zarr v3 and in the ``.zmetadata`` file - for Zarr v2). + store (in the ``zarr.json`` for Zarr format 3 and in the ``.zmetadata`` file + for Zarr format 2). To explicitly require consolidated metadata, set ``use_consolidated=True``, which will raise an exception if consolidated metadata is not found. @@ -511,7 +511,7 @@ def open_group( To explicitly *not* use consolidated metadata, set ``use_consolidated=False``, which will fall back to using the regular, non consolidated metadata. - Zarr v2 allowed configuring the key storing the consolidated metadata + Zarr format 2 allowed configuring the key storing the consolidated metadata (``.zmetadata`` by default). Specify the custom key as ``use_consolidated`` to load consolidated metadata from a non-default key. @@ -785,16 +785,16 @@ def create_array( Iterable of filters to apply to each chunk of the array, in order, before serializing that chunk to bytes. - For Zarr v3, a "filter" is a codec that takes an array and returns an array, + For Zarr format 3, a "filter" is a codec that takes an array and returns an array, and these values must be instances of ``ArrayArrayCodec``, or dict representations of ``ArrayArrayCodec``. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default filters. - For Zarr v2, a "filter" can be any numcodecs codec; you should ensure that the + For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the the order if your filters is consistent with the behavior of each filter. If no ``filters`` are provided, a default set of filters will be used. These defaults can be changed by modifying the value of ``array.v2_default_filters`` @@ -804,32 +804,32 @@ def create_array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr v3, a "compressor" is a codec that takes a bytestrea, and - returns another bytestream. Multiple compressors my be provided for Zarr v3. + For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default compressors. - For Zarr v2, a "compressor" can be any numcodecs codec. Only a single compressor may - be provided for Zarr v2. + For Zarr format 2, a "compressor" can be any numcodecs codec. Only a single compressor may + be provided for Zarr format 2. If no ``compressors`` are provided, a default compressor will be used. These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`. Use ``None`` to omit the default compressor. serializer : dict[str, JSON] | ArrayBytesCodec, optional Array-to-bytes codec to use for encoding the array data. - Zarr v3 only. Zarr v2 arrays use implicit array-to-bytes conversion. + Zarr format 3 only. Zarr format 2 arrays use implicit array-to-bytes conversion. If no ``serializer`` is provided, the `zarr.codecs.BytesCodec` codec will be used. fill_value : Any, optional Fill value for the array. order : {"C", "F"}, optional The memory of the array (default is "C"). - For Zarr v2, this parameter sets the memory order of the array. - For Zarr v3, this parameter is deprecated, because memory order - is a runtime parameter for Zarr v3 arrays. The recommended way to specify the memory - order for Zarr v3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. + For Zarr format 2, this parameter sets the memory order of the array. + For Zarr format 3, this parameter is deprecated, because memory order + is a runtime parameter for Zarr format 3 arrays. The recommended way to specify the memory + order for Zarr format 3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. If no ``order`` is provided, a default order will be used. This default can be changed by modifying the value of ``array.order`` in :mod:`zarr.core.config`. zarr_format : {2, 3}, optional @@ -838,11 +838,11 @@ def create_array( Attributes for the array. chunk_key_encoding : ChunkKeyEncoding, optional A specification of how the chunk keys are represented in storage. - For Zarr v3, the default is ``{"name": "default", "separator": "/"}}``. - For Zarr v2, the default is ``{"name": "v2", "separator": "."}}``. + For Zarr format 3, the default is ``{"name": "default", "separator": "/"}}``. + For Zarr format 2, the default is ``{"name": "v2", "separator": "."}}``. dimension_names : Iterable[str], optional The names of the dimensions (default is None). - Zarr v3 only. Zarr v2 arrays should not use this parameter. + Zarr format 3 only. Zarr format 2 arrays should not use this parameter. storage_options : dict, optional If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise. diff --git a/src/zarr/codecs/vlen_utf8.py b/src/zarr/codecs/vlen_utf8.py index e5b895ae0c..0ef423793d 100644 --- a/src/zarr/codecs/vlen_utf8.py +++ b/src/zarr/codecs/vlen_utf8.py @@ -28,7 +28,7 @@ class VLenUTF8Codec(ArrayBytesCodec): def __init__(self) -> None: warn( - "The codec `vlen-utf8` is currently not part in the Zarr version 3 specification. It " + "The codec `vlen-utf8` is currently not part in the Zarr format 3 specification. It " "may not be supported by other zarr implementations and may change in the future.", category=UserWarning, stacklevel=2, @@ -83,7 +83,7 @@ def compute_encoded_size(self, input_byte_length: int, _chunk_spec: ArraySpec) - class VLenBytesCodec(ArrayBytesCodec): def __init__(self) -> None: warn( - "The codec `vlen-bytes` is currently not part in the Zarr version 3 specification. It " + "The codec `vlen-bytes` is currently not part in the Zarr format 3 specification. It " "may not be supported by other zarr implementations and may change in the future.", category=UserWarning, stacklevel=2, diff --git a/src/zarr/core/array.py b/src/zarr/core/array.py index 6d8aca20ec..5ce50113dd 100644 --- a/src/zarr/core/array.py +++ b/src/zarr/core/array.py @@ -179,7 +179,7 @@ async def get_array_metadata( ) if zarr_json_bytes is not None and zarray_bytes is not None: # warn and favor v3 - msg = f"Both zarr.json (Zarr v3) and .zarray (Zarr v2) metadata objects exist at {store_path}. Zarr v3 will be used." + msg = f"Both zarr.json (Zarr format 3) and .zarray (Zarr format 2) metadata objects exist at {store_path}. Zarr v3 will be used." warnings.warn(msg, stacklevel=1) if zarr_json_bytes is None and zarray_bytes is None: raise FileNotFoundError(store_path) @@ -448,16 +448,16 @@ async def create( The attributes of the array (default is None). chunk_shape : ChunkCoords, optional The shape of the array's chunks - V3 only. V2 arrays should use `chunks` instead. + Zarr format 3 only. Zarr format 2 arrays should use `chunks` instead. If not specified, default are guessed based on the shape and dtype. chunk_key_encoding : ChunkKeyEncoding, optional A specification of how the chunk keys are represented in storage. - V3 only. V2 arrays should use `dimension_separator` instead. + Zarr format 3 only. Zarr format 2 arrays should use `dimension_separator` instead. Default is ``("default", "/")``. codecs : Sequence of Codecs or dicts, optional An iterable of Codec or dict serializations of Codecs. The elements of this collection specify the transformation from array values to stored bytes. - V3 only. V2 arrays should use ``filters`` and ``compressor`` instead. + Zarr format 3 only. Zarr format 2 arrays should use ``filters`` and ``compressor`` instead. If no codecs are provided, default codecs will be used: @@ -468,14 +468,14 @@ async def create( These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. dimension_names : Iterable[str], optional The names of the dimensions (default is None). - V3 only. V2 arrays should not use this parameter. + Zarr format 3 only. Zarr format 2 arrays should not use this parameter. chunks : ShapeLike, optional The shape of the array's chunks. - V2 only. V3 arrays should use ``chunk_shape`` instead. + Zarr format 2 only. Zarr format 3 arrays should use ``chunk_shape`` instead. If not specified, default are guessed based on the shape and dtype. dimension_separator : Literal[".", "/"], optional The dimension separator (default is "."). - V2 only. V3 arrays should use ``chunk_key_encoding`` instead. + Zarr format 2 only. Zarr format 3 arrays should use ``chunk_key_encoding`` instead. order : Literal["C", "F"], optional The memory of the array (default is "C"). If ``zarr_format`` is 2, this parameter sets the memory order of the array. @@ -484,12 +484,12 @@ async def create( order for Zarr 3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. filters : list[dict[str, JSON]], optional Sequence of filters to use to encode chunk data prior to compression. - V2 only. V3 arrays should use ``codecs`` instead. If no ``filters`` + Zarr format 2 only. Zarr format 3 arrays should use ``codecs`` instead. If no ``filters`` are provided, a default set of filters will be used. These defaults can be changed by modifying the value of ``array.v2_default_filters`` in :mod:`zarr.core.config`. compressor : dict[str, JSON], optional The compressor used to compress the data (default is None). - V2 only. V3 arrays should use ``codecs`` instead. + Zarr format 2 only. Zarr format 3 arrays should use ``codecs`` instead. If no ``compressor`` is provided, a default compressor will be used: @@ -592,15 +592,15 @@ async def _create( if zarr_format == 3: if dimension_separator is not None: raise ValueError( - "dimension_separator cannot be used for arrays with version 3. Use chunk_key_encoding instead." + "dimension_separator cannot be used for arrays with zarr_format 3. Use chunk_key_encoding instead." ) if filters is not None: raise ValueError( - "filters cannot be used for arrays with version 3. Use array-to-array codecs instead." + "filters cannot be used for arrays with zarr_format 3. Use array-to-array codecs instead." ) if compressor is not None: raise ValueError( - "compressor cannot be used for arrays with version 3. Use bytes-to-bytes codecs instead." + "compressor cannot be used for arrays with zarr_format 3. Use bytes-to-bytes codecs instead." ) if order is not None: @@ -622,14 +622,14 @@ async def _create( elif zarr_format == 2: if codecs is not None: raise ValueError( - "codecs cannot be used for arrays with version 2. Use filters and compressor instead." + "codecs cannot be used for arrays with zarr_format 2. Use filters and compressor instead." ) if chunk_key_encoding is not None: raise ValueError( - "chunk_key_encoding cannot be used for arrays with version 2. Use dimension_separator instead." + "chunk_key_encoding cannot be used for arrays with zarr_format 2. Use dimension_separator instead." ) if dimension_names is not None: - raise ValueError("dimension_names cannot be used for arrays with version 2.") + raise ValueError("dimension_names cannot be used for arrays with zarr_format 2.") if order is None: order_parsed = parse_order(zarr_config.get("array.order")) @@ -704,7 +704,7 @@ async def _create_v3( if dtype.kind in "UTS": warn( - f"The dtype `{dtype}` is currently not part in the Zarr version 3 specification. It " + f"The dtype `{dtype}` is currently not part in the Zarr format 3 specification. It " "may not be supported by other zarr implementations and may change in the future.", category=UserWarning, stacklevel=2, @@ -785,7 +785,7 @@ def from_dict( data: dict[str, JSON], ) -> AsyncArray[ArrayV3Metadata] | AsyncArray[ArrayV2Metadata]: """ - Create a Zarr array from a dictionary, with support for both Zarr v2 and v3 metadata. + Create a Zarr array from a dictionary, with support for both Zarr format 2 and 3 metadata. Parameters ---------- @@ -795,17 +795,17 @@ def from_dict( data : dict A dictionary representing the array data. This dictionary should include necessary metadata for the array, such as shape, dtype, and other attributes. The format of the metadata - will determine whether a Zarr v2 or v3 array is created. + will determine whether a Zarr format 2 or 3 array is created. Returns ------- AsyncArray[ArrayV3Metadata] or AsyncArray[ArrayV2Metadata] - The created Zarr array, either using v2 or v3 metadata based on the provided data. + The created Zarr array, either using Zarr format 2 or 3 metadata based on the provided data. Raises ------ ValueError - If the dictionary data is invalid or incompatible with either Zarr v2 or v3 array creation. + If the dictionary data is invalid or incompatible with either Zarr format 2 or 3 array creation. """ metadata = parse_array_metadata(data) return cls(metadata=metadata, store_path=store_path) @@ -1647,16 +1647,16 @@ def create( The data type of the array. chunk_shape : ChunkCoords, optional The shape of the Array's chunks. - V3 only. V2 arrays should use `chunks` instead. + Zarr format 3 only. Zarr format 2 arrays should use `chunks` instead. If not specified, default are guessed based on the shape and dtype. chunk_key_encoding : ChunkKeyEncoding, optional A specification of how the chunk keys are represented in storage. - V3 only. V2 arrays should use `dimension_separator` instead. + Zarr format 3 only. Zarr format 2 arrays should use `dimension_separator` instead. Default is ``("default", "/")``. codecs : Sequence of Codecs or dicts, optional An iterable of Codec or dict serializations of Codecs. The elements of this collection specify the transformation from array values to stored bytes. - V3 only. V2 arrays should use ``filters`` and ``compressor`` instead. + Zarr format 3 only. Zarr format 2 arrays should use ``filters`` and ``compressor`` instead. If no codecs are provided, default codecs will be used: @@ -1667,14 +1667,14 @@ def create( These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. dimension_names : Iterable[str], optional The names of the dimensions (default is None). - V3 only. V2 arrays should not use this parameter. + Zarr format 3 only. Zarr format 2 arrays should not use this parameter. chunks : ChunkCoords, optional The shape of the array's chunks. - V2 only. V3 arrays should use ``chunk_shape`` instead. + Zarr format 2 only. Zarr format 3 arrays should use ``chunk_shape`` instead. If not specified, default are guessed based on the shape and dtype. dimension_separator : Literal[".", "/"], optional The dimension separator (default is "."). - V2 only. V3 arrays should use ``chunk_key_encoding`` instead. + Zarr format 2 only. Zarr format 3 arrays should use ``chunk_key_encoding`` instead. order : Literal["C", "F"], optional The memory of the array (default is "C"). If ``zarr_format`` is 2, this parameter sets the memory order of the array. @@ -1683,12 +1683,12 @@ def create( order for Zarr 3 arrays is via the ``config`` parameter, e.g. ``{'order': 'C'}``. filters : list[dict[str, JSON]], optional Sequence of filters to use to encode chunk data prior to compression. - V2 only. V3 arrays should use ``codecs`` instead. If no ``filters`` + Zarr format 2 only. Zarr format 3 arrays should use ``codecs`` instead. If no ``filters`` are provided, a default set of filters will be used. These defaults can be changed by modifying the value of ``array.v2_default_filters`` in :mod:`zarr.core.config`. compressor : dict[str, JSON], optional Primary compressor to compress chunk data. - V2 only. V3 arrays should use ``codecs`` instead. + Zarr format 2 only. Zarr format 3 arrays should use ``codecs`` instead. If no ``compressor`` is provided, a default compressor will be used: @@ -2245,7 +2245,7 @@ def __getitem__(self, selection: Selection) -> NDArrayLike: ----- Slices with step > 1 are supported, but slices with negative step are not. - For arrays with a structured dtype, see zarr v2 for examples of how to use + For arrays with a structured dtype, see Zarr format 2 for examples of how to use fields Currently the implementation for __getitem__ is provided by @@ -2344,7 +2344,7 @@ def __setitem__(self, selection: Selection, value: npt.ArrayLike) -> None: ----- Slices with step > 1 are supported, but slices with negative step are not. - For arrays with a structured dtype, see zarr v2 for examples of how to use + For arrays with a structured dtype, see Zarr format 2 for examples of how to use fields Currently the implementation for __setitem__ is provided by @@ -2476,7 +2476,7 @@ def get_basic_selection( ----- Slices with step > 1 are supported, but slices with negative step are not. - For arrays with a structured dtype, see zarr v2 for examples of how to use + For arrays with a structured dtype, see Zarr format 2 for examples of how to use the `fields` parameter. This method provides the implementation for accessing data via the @@ -2579,7 +2579,7 @@ def set_basic_selection( Notes ----- - For arrays with a structured dtype, see zarr v2 for examples of how to use + For arrays with a structured dtype, see Zarr format 2 for examples of how to use the `fields` parameter. This method provides the underlying implementation for modifying data via square @@ -3699,16 +3699,16 @@ async def create_array( Iterable of filters to apply to each chunk of the array, in order, before serializing that chunk to bytes. - For Zarr v3, a "filter" is a codec that takes an array and returns an array, + For Zarr format 3, a "filter" is a codec that takes an array and returns an array, and these values must be instances of ``ArrayArrayCodec``, or dict representations of ``ArrayArrayCodec``. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default filters. - For Zarr v2, a "filter" can be any numcodecs codec; you should ensure that the + For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the the order if your filters is consistent with the behavior of each filter. If no ``filters`` are provided, a default set of filters will be used. These defaults can be changed by modifying the value of ``array.v2_default_filters`` @@ -3718,32 +3718,32 @@ async def create_array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr v3, a "compressor" is a codec that takes a bytestrea, and - returns another bytestream. Multiple compressors my be provided for Zarr v3. + For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default compressors. - For Zarr v2, a "compressor" can be any numcodecs codec. Only a single compressor may - be provided for Zarr v2. + For Zarr format 2, a "compressor" can be any numcodecs codec. Only a single compressor may + be provided for Zarr format 2. If no ``compressors`` are provided, a default compressor will be used. These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`. Use ``None`` to omit the default compressor. serializer : dict[str, JSON] | ArrayBytesCodec, optional Array-to-bytes codec to use for encoding the array data. - Zarr v3 only. Zarr v2 arrays use implicit array-to-bytes conversion. + Zarr format 3 only. Zarr format 2 arrays use implicit array-to-bytes conversion. If no ``serializer`` is provided, the `zarr.codecs.BytesCodec` codec will be used. fill_value : Any, optional Fill value for the array. order : {"C", "F"}, optional The memory of the array (default is "C"). - For Zarr v2, this parameter sets the memory order of the array. - For Zarr v3, this parameter is deprecated, because memory order - is a runtime parameter for Zarr v3 arrays. The recommended way to specify the memory - order for Zarr v3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. + For Zarr format 2, this parameter sets the memory order of the array. + For Zarr format 3, this parameter is deprecated, because memory order + is a runtime parameter for Zarr format 3 arrays. The recommended way to specify the memory + order for Zarr format 3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. If no ``order`` is provided, a default order will be used. This default can be changed by modifying the value of ``array.order`` in :mod:`zarr.core.config`. zarr_format : {2, 3}, optional @@ -3752,11 +3752,11 @@ async def create_array( Attributes for the array. chunk_key_encoding : ChunkKeyEncoding, optional A specification of how the chunk keys are represented in storage. - For Zarr v3, the default is ``{"name": "default", "separator": "/"}}``. - For Zarr v2, the default is ``{"name": "v2", "separator": "."}}``. + For Zarr format 3, the default is ``{"name": "default", "separator": "/"}}``. + For Zarr format 2, the default is ``{"name": "v2", "separator": "."}}``. dimension_names : Iterable[str], optional The names of the dimensions (default is None). - Zarr v3 only. Zarr v2 arrays should not use this parameter. + Zarr format 3 only. Zarr format 2 arrays should not use this parameter. storage_options : dict, optional If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise. @@ -3805,20 +3805,20 @@ async def create_array( if zarr_format == 2: if shard_shape_parsed is not None: msg = ( - "Zarr v2 arrays can only be created with `shard_shape` set to `None`. " + "Zarr format 2 arrays can only be created with `shard_shape` set to `None`. " f"Got `shard_shape={shards}` instead." ) raise ValueError(msg) if serializer != "auto": - raise ValueError("Zarr v2 arrays do not support `serializer`.") + raise ValueError("Zarr format 2 arrays do not support `serializer`.") filters_parsed, compressor_parsed = _parse_chunk_encoding_v2( compressor=compressors, filters=filters, dtype=np.dtype(dtype) ) if dimension_names is not None: - raise ValueError("Zarr v2 arrays do not support dimension names.") + raise ValueError("Zarr format 2 arrays do not support dimension names.") if order is None: order_parsed = zarr_config.get("array.order") else: @@ -3901,7 +3901,7 @@ def _parse_chunk_key_encoding( result = ChunkKeyEncoding.from_dict(data) if zarr_format == 2 and result.name != "v2": msg = ( - "Invalid chunk key encoding. For Zarr v2 arrays, the `name` field of the " + "Invalid chunk key encoding. For Zarr format 2 arrays, the `name` field of the " f"chunk key encoding must be 'v2'. Got `name` = {result.name} instead." ) raise ValueError(msg) @@ -3954,7 +3954,7 @@ def _get_default_chunk_encoding_v2( np_dtype: np.dtype[Any], ) -> tuple[tuple[numcodecs.abc.Codec, ...] | None, numcodecs.abc.Codec | None]: """ - Get the default chunk encoding for zarr v2 arrays, given a dtype + Get the default chunk encoding for Zarr format 2 arrays, given a dtype """ compressor_dict = _default_compressor(np_dtype) @@ -3978,7 +3978,7 @@ def _parse_chunk_encoding_v2( dtype: np.dtype[Any], ) -> tuple[tuple[numcodecs.abc.Codec, ...] | None, numcodecs.abc.Codec | None]: """ - Generate chunk encoding classes for v2 arrays with optional defaults. + Generate chunk encoding classes for Zarr format 2 arrays with optional defaults. """ default_filters, default_compressor = _get_default_chunk_encoding_v2(dtype) @@ -3993,7 +3993,7 @@ def _parse_chunk_encoding_v2( _compressor = parse_compressor(compressor[0]) else: if isinstance(compressor, Iterable) and not isinstance(compressor, dict): - msg = f"For Zarr v2 arrays, the `compressor` must be a single codec. Got an iterable with type {type(compressor)} instead." + msg = f"For Zarr format 2 arrays, the `compressor` must be a single codec. Got an iterable with type {type(compressor)} instead." raise TypeError(msg) _compressor = parse_compressor(compressor) @@ -4006,7 +4006,7 @@ def _parse_chunk_encoding_v2( for idx, f in enumerate(filters): if not isinstance(f, numcodecs.abc.Codec): msg = ( - "For Zarr v2 arrays, all elements of `filters` must be numcodecs codecs. " + "For Zarr format 2 arrays, all elements of `filters` must be numcodecs codecs. " f"Element at index {idx} has type {type(f)}, which is not a numcodecs codec." ) raise TypeError(msg) diff --git a/src/zarr/core/common.py b/src/zarr/core/common.py index d53f3847a5..7205b8c206 100644 --- a/src/zarr/core/common.py +++ b/src/zarr/core/common.py @@ -192,7 +192,7 @@ def _warn_write_empty_chunks_kwarg() -> None: def _warn_order_kwarg() -> None: # TODO: link to docs page on array configuration in this message msg = ( - "The `order` keyword argument has no effect for zarr v3 arrays. " + "The `order` keyword argument has no effect for Zarr format 3 arrays. " "To control the memory layout of the array, either use the `config` keyword " "argument, as in `config={'order: 'C'}`," "or change the global 'array.order' configuration variable." diff --git a/src/zarr/core/group.py b/src/zarr/core/group.py index 7a0d2efc09..723398a00d 100644 --- a/src/zarr/core/group.py +++ b/src/zarr/core/group.py @@ -459,8 +459,8 @@ async def open( Whether to use consolidated metadata. By default, consolidated metadata is used if it's present in the - store (in the ``zarr.json`` for Zarr v3 and in the ``.zmetadata`` file - for Zarr v2). + store (in the ``zarr.json`` for Zarr format 3 and in the ``.zmetadata`` file + for Zarr format 2). To explicitly require consolidated metadata, set ``use_consolidated=True``, which will raise an exception if consolidated metadata is not found. @@ -468,7 +468,7 @@ async def open( To explicitly *not* use consolidated metadata, set ``use_consolidated=False``, which will fall back to using the regular, non consolidated metadata. - Zarr v2 allowed configuring the key storing the consolidated metadata + Zarr format 2 allowed configuring the key storing the consolidated metadata (``.zmetadata`` by default). Specify the custom key as ``use_consolidated`` to load consolidated metadata from a non-default key. """ @@ -514,7 +514,7 @@ async def open( ) if zarr_json_bytes is not None and zgroup_bytes is not None: # warn and favor v3 - msg = f"Both zarr.json (Zarr v3) and .zgroup (Zarr v2) metadata objects exist at {store_path}. Zarr v3 will be used." + msg = f"Both zarr.json (Zarr format 3) and .zgroup (Zarr format 2) metadata objects exist at {store_path}. Zarr format 3 will be used." warnings.warn(msg, stacklevel=1) if zarr_json_bytes is None and zgroup_bytes is None: raise FileNotFoundError( @@ -548,7 +548,7 @@ async def open( # V3 groups are comprised of a zarr.json object assert zarr_json_bytes is not None if not isinstance(use_consolidated, bool | None): - raise TypeError("use_consolidated must be a bool or None for Zarr V3.") + raise TypeError("use_consolidated must be a bool or None for Zarr format 3.") return cls._from_bytes_v3( store_path, @@ -1048,16 +1048,16 @@ async def create_array( Iterable of filters to apply to each chunk of the array, in order, before serializing that chunk to bytes. - For Zarr v3, a "filter" is a codec that takes an array and returns an array, + For Zarr format 3, a "filter" is a codec that takes an array and returns an array, and these values must be instances of ``ArrayArrayCodec``, or dict representations of ``ArrayArrayCodec``. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default filters. - For Zarr v2, a "filter" can be any numcodecs codec; you should ensure that the + For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the the order if your filters is consistent with the behavior of each filter. If no ``filters`` are provided, a default set of filters will be used. These defaults can be changed by modifying the value of ``array.v2_default_filters`` @@ -1067,16 +1067,16 @@ async def create_array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr v3, a "compressor" is a codec that takes a bytestrea, and - returns another bytestream. Multiple compressors my be provided for Zarr v3. + For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default compressors. - For Zarr v2, a "compressor" can be any numcodecs codec. Only a single compressor may - be provided for Zarr v2. + For Zarr format 2, a "compressor" can be any numcodecs codec. Only a single compressor may + be provided for Zarr format 2. If no ``compressors`` are provided, a default compressor will be used. These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`. @@ -1085,27 +1085,27 @@ async def create_array( Deprecated in favor of ``compressors``. serializer : dict[str, JSON] | ArrayBytesCodec, optional Array-to-bytes codec to use for encoding the array data. - Zarr v3 only. Zarr v2 arrays use implicit array-to-bytes conversion. + Zarr format 3 only. Zarr format 2 arrays use implicit array-to-bytes conversion. If no ``serializer`` is provided, the `zarr.codecs.BytesCodec` codec will be used. fill_value : Any, optional Fill value for the array. order : {"C", "F"}, optional The memory of the array (default is "C"). - For Zarr v2, this parameter sets the memory order of the array. - For Zarr v3, this parameter is deprecated, because memory order - is a runtime parameter for Zarr v3 arrays. The recommended way to specify the memory - order for Zarr v3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. + For Zarr format 2, this parameter sets the memory order of the array. + For Zarr format 3, this parameter is deprecated, because memory order + is a runtime parameter for Zarr format 3 arrays. The recommended way to specify the memory + order for Zarr format 3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. If no ``order`` is provided, a default order will be used. This default can be changed by modifying the value of ``array.order`` in :mod:`zarr.core.config`. attributes : dict, optional Attributes for the array. chunk_key_encoding : ChunkKeyEncoding, optional A specification of how the chunk keys are represented in storage. - For Zarr v3, the default is ``{"name": "default", "separator": "/"}}``. - For Zarr v2, the default is ``{"name": "v2", "separator": "."}}``. + For Zarr format 3, the default is ``{"name": "default", "separator": "/"}}``. + For Zarr format 2, the default is ``{"name": "v2", "separator": "."}}``. dimension_names : Iterable[str], optional The names of the dimensions (default is None). - Zarr v3 only. Zarr v2 arrays should not use this parameter. + Zarr format 3 only. Zarr format 2 arrays should not use this parameter. storage_options : dict, optional If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise. @@ -2295,16 +2295,16 @@ def create_array( Iterable of filters to apply to each chunk of the array, in order, before serializing that chunk to bytes. - For Zarr v3, a "filter" is a codec that takes an array and returns an array, + For Zarr format 3, a "filter" is a codec that takes an array and returns an array, and these values must be instances of ``ArrayArrayCodec``, or dict representations of ``ArrayArrayCodec``. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default filters. - For Zarr v2, a "filter" can be any numcodecs codec; you should ensure that the + For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the the order if your filters is consistent with the behavior of each filter. If no ``filters`` are provided, a default set of filters will be used. These defaults can be changed by modifying the value of ``array.v2_default_filters`` @@ -2314,16 +2314,16 @@ def create_array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr v3, a "compressor" is a codec that takes a bytestrea, and - returns another bytestream. Multiple compressors my be provided for Zarr v3. + For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default compressors. - For Zarr v2, a "compressor" can be any numcodecs codec. Only a single compressor may - be provided for Zarr v2. + For Zarr format 2, a "compressor" can be any numcodecs codec. Only a single compressor may + be provided for Zarr format 2. If no ``compressors`` are provided, a default compressor will be used. These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`. @@ -2332,27 +2332,27 @@ def create_array( Deprecated in favor of ``compressors``. serializer : dict[str, JSON] | ArrayBytesCodec, optional Array-to-bytes codec to use for encoding the array data. - Zarr v3 only. Zarr v2 arrays use implicit array-to-bytes conversion. + Zarr format 3 only. Zarr format 2 arrays use implicit array-to-bytes conversion. If no ``serializer`` is provided, the `zarr.codecs.BytesCodec` codec will be used. fill_value : Any, optional Fill value for the array. order : {"C", "F"}, optional The memory of the array (default is "C"). - For Zarr v2, this parameter sets the memory order of the array. - For Zarr v3, this parameter is deprecated, because memory order - is a runtime parameter for Zarr v3 arrays. The recommended way to specify the memory - order for Zarr v3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. + For Zarr format 2, this parameter sets the memory order of the array. + For Zarr format 3, this parameter is deprecated, because memory order + is a runtime parameter for Zarr format 3 arrays. The recommended way to specify the memory + order for Zarr format 3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. If no ``order`` is provided, a default order will be used. This default can be changed by modifying the value of ``array.order`` in :mod:`zarr.core.config`. attributes : dict, optional Attributes for the array. chunk_key_encoding : ChunkKeyEncoding, optional A specification of how the chunk keys are represented in storage. - For Zarr v3, the default is ``{"name": "default", "separator": "/"}}``. - For Zarr v2, the default is ``{"name": "v2", "separator": "."}}``. + For Zarr format 3, the default is ``{"name": "default", "separator": "/"}}``. + For Zarr format 2, the default is ``{"name": "v2", "separator": "."}}``. dimension_names : Iterable[str], optional The names of the dimensions (default is None). - Zarr v3 only. Zarr v2 arrays should not use this parameter. + Zarr format 3 only. Zarr format 2 arrays should not use this parameter. storage_options : dict, optional If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise. @@ -2680,16 +2680,16 @@ def array( Iterable of filters to apply to each chunk of the array, in order, before serializing that chunk to bytes. - For Zarr v3, a "filter" is a codec that takes an array and returns an array, + For Zarr format 3, a "filter" is a codec that takes an array and returns an array, and these values must be instances of ``ArrayArrayCodec``, or dict representations of ``ArrayArrayCodec``. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default filters. - For Zarr v2, a "filter" can be any numcodecs codec; you should ensure that the + For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the the order if your filters is consistent with the behavior of each filter. If no ``filters`` are provided, a default set of filters will be used. These defaults can be changed by modifying the value of ``array.v2_default_filters`` @@ -2699,16 +2699,16 @@ def array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr v3, a "compressor" is a codec that takes a bytestrea, and - returns another bytestream. Multiple compressors my be provided for Zarr v3. + For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for - Zarr v3 will be used. + Zarr format 3 will be used. These defaults can be changed by modifying the value of ``array.v3_default_codecs`` in :mod:`zarr.core.config`. Use ``None`` to omit default compressors. - For Zarr v2, a "compressor" can be any numcodecs codec. Only a single compressor may - be provided for Zarr v2. + For Zarr format 2, a "compressor" can be any numcodecs codec. Only a single compressor may + be provided for Zarr format 2. If no ``compressors`` are provided, a default compressor will be used. These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`. @@ -2717,27 +2717,27 @@ def array( Deprecated in favor of ``compressors``. serializer : dict[str, JSON] | ArrayBytesCodec, optional Array-to-bytes codec to use for encoding the array data. - Zarr v3 only. Zarr v2 arrays use implicit array-to-bytes conversion. + Zarr format 3 only. Zarr format 2 arrays use implicit array-to-bytes conversion. If no ``serializer`` is provided, the `zarr.codecs.BytesCodec` codec will be used. fill_value : Any, optional Fill value for the array. order : {"C", "F"}, optional The memory of the array (default is "C"). - For Zarr v2, this parameter sets the memory order of the array. - For Zarr v3, this parameter is deprecated, because memory order - is a runtime parameter for Zarr v3 arrays. The recommended way to specify the memory - order for Zarr v3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. + For Zarr format 2, this parameter sets the memory order of the array. + For Zarr format 3, this parameter is deprecated, because memory order + is a runtime parameter for Zarr format 3 arrays. The recommended way to specify the memory + order for Zarr format 3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``. If no ``order`` is provided, a default order will be used. This default can be changed by modifying the value of ``array.order`` in :mod:`zarr.core.config`. attributes : dict, optional Attributes for the array. chunk_key_encoding : ChunkKeyEncoding, optional A specification of how the chunk keys are represented in storage. - For Zarr v3, the default is ``{"name": "default", "separator": "/"}}``. - For Zarr v2, the default is ``{"name": "v2", "separator": "."}}``. + For Zarr format 3, the default is ``{"name": "default", "separator": "/"}}``. + For Zarr format 2, the default is ``{"name": "v2", "separator": "."}}``. dimension_names : Iterable[str], optional The names of the dimensions (default is None). - Zarr v3 only. Zarr v2 arrays should not use this parameter. + Zarr format 3 only. Zarr format 2 arrays should not use this parameter. storage_options : dict, optional If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise. diff --git a/src/zarr/core/metadata/v2.py b/src/zarr/core/metadata/v2.py index bc7fd32cbf..b95433068a 100644 --- a/src/zarr/core/metadata/v2.py +++ b/src/zarr/core/metadata/v2.py @@ -34,7 +34,7 @@ class ArrayV2MetadataDict(TypedDict): """ - A typed dictionary model for zarr v2 metadata. + A typed dictionary model for Zarr format 2 metadata. """ zarr_format: Literal[2] @@ -68,7 +68,7 @@ def __init__( attributes: dict[str, JSON] | None = None, ) -> None: """ - Metadata for a Zarr version 2 array. + Metadata for a Zarr format 2 array. """ shape_parsed = parse_shapelike(shape) dtype_parsed = parse_dtype(dtype) @@ -327,7 +327,7 @@ def _default_fill_value(dtype: np.dtype[Any]) -> Any: stored in the Array metadata into an in-memory value. This only gives the default fill value for some type. - This is useful for reading Zarr V2 arrays, which allow the fill + This is useful for reading Zarr format 2 arrays, which allow the fill value to be unspecified. """ if dtype.kind == "S": diff --git a/src/zarr/core/metadata/v3.py b/src/zarr/core/metadata/v3.py index 0821dd9bc9..1265c832b2 100644 --- a/src/zarr/core/metadata/v3.py +++ b/src/zarr/core/metadata/v3.py @@ -468,7 +468,7 @@ def parse_fill_value( fill_value : Any A potential fill value. dtype : str - A valid Zarr V3 DataType. + A valid Zarr format 3 DataType. Returns ------- @@ -676,10 +676,10 @@ def parse(cls, dtype: DataType | Any | None) -> DataType: try: dtype = np.dtype(dtype) except (ValueError, TypeError) as e: - raise ValueError(f"Invalid V3 data_type: {dtype}") from e + raise ValueError(f"Invalid Zarr format 3 data_type: {dtype}") from e # check that this is a valid v3 data_type try: data_type = DataType.from_numpy(dtype) except KeyError as e: - raise ValueError(f"Invalid V3 data_type: {dtype}") from e + raise ValueError(f"Invalid Zarr format 3 data_type: {dtype}") from e return data_type diff --git a/tests/test_array.py b/tests/test_array.py index 51ad289e80..9665d4e7fe 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -1171,7 +1171,7 @@ async def test_create_array_v2_no_shards(store: MemoryStore) -> None: Test that creating a Zarr v2 array with ``shard_shape`` set to a non-None value raises an error. """ msg = re.escape( - "Zarr v2 arrays can only be created with `shard_shape` set to `None`. Got `shard_shape=(5,)` instead." + "Zarr format 2 arrays can only be created with `shard_shape` set to `None`. Got `shard_shape=(5,)` instead." ) with pytest.raises(ValueError, match=msg): _ = await create_array( diff --git a/tests/test_metadata/test_v3.py b/tests/test_metadata/test_v3.py index 6f7fba6dd1..ef527f42ef 100644 --- a/tests/test_metadata/test_v3.py +++ b/tests/test_metadata/test_v3.py @@ -336,13 +336,13 @@ def test_invalid_dtype_raises() -> None: "codecs": (), "fill_value": np.datetime64(0, "ns"), } - with pytest.raises(ValueError, match=r"Invalid V3 data_type: .*"): + with pytest.raises(ValueError, match=r"Invalid Zarr format 3 data_type: .*"): ArrayV3Metadata.from_dict(metadata_dict) @pytest.mark.parametrize("data", ["datetime64[s]", "foo", object()]) def test_parse_invalid_dtype_raises(data): - with pytest.raises(ValueError, match=r"Invalid V3 data_type: .*"): + with pytest.raises(ValueError, match=r"Invalid Zarr format 3 data_type: .*"): DataType.parse(data) From c0363fc20f2a95f9d7ceefd838b38aba12dc1f07 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Sun, 5 Jan 2025 14:20:56 +0100 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: David Stansby --- docs/user-guide/extending.rst | 2 +- src/zarr/api/synchronous.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/extending.rst b/docs/user-guide/extending.rst index 08ce257387..7647703fbb 100644 --- a/docs/user-guide/extending.rst +++ b/docs/user-guide/extending.rst @@ -10,7 +10,7 @@ Custom codecs ------------- .. note:: - This section explains how custom codecs can be created for Zarr format 3 data. For Zarr + This section explains how custom codecs can be created for Zarr format 3 arrays. For Zarr format 2, codecs should subclass the `numcodecs.abc.Codec `_ base class and register through diff --git a/src/zarr/api/synchronous.py b/src/zarr/api/synchronous.py index 174e2390a6..86810c0abb 100644 --- a/src/zarr/api/synchronous.py +++ b/src/zarr/api/synchronous.py @@ -511,7 +511,7 @@ def open_group( To explicitly *not* use consolidated metadata, set ``use_consolidated=False``, which will fall back to using the regular, non consolidated metadata. - Zarr format 2 allowed configuring the key storing the consolidated metadata + Zarr format 2 allows configuring the key storing the consolidated metadata (``.zmetadata`` by default). Specify the custom key as ``use_consolidated`` to load consolidated metadata from a non-default key. @@ -804,7 +804,7 @@ def create_array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + For Zarr format 3, a "compressor" is a codec that takes a bytestream, and returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for Zarr format 3 will be used. From 44da2df2f591aeb722ab9777fc5c76b92ec3eb79 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Sun, 5 Jan 2025 14:33:39 +0100 Subject: [PATCH 3/4] Update src/zarr/core/array.py Co-authored-by: David Stansby --- src/zarr/core/array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zarr/core/array.py b/src/zarr/core/array.py index 5ce50113dd..add646108b 100644 --- a/src/zarr/core/array.py +++ b/src/zarr/core/array.py @@ -3718,7 +3718,7 @@ async def create_array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + For Zarr format 3, a "compressor" is a codec that takes a bytestream, and returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for Zarr format 3 will be used. From 19510e95f7ee93c881f33fd3a068fc7dd991af00 Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Sun, 5 Jan 2025 14:39:55 +0100 Subject: [PATCH 4/4] typo --- src/zarr/core/group.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/zarr/core/group.py b/src/zarr/core/group.py index 723398a00d..8c0f2bc6a8 100644 --- a/src/zarr/core/group.py +++ b/src/zarr/core/group.py @@ -1067,7 +1067,7 @@ async def create_array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + For Zarr format 3, a "compressor" is a codec that takes a bytestream, and returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for Zarr format 3 will be used. @@ -2314,7 +2314,7 @@ def create_array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + For Zarr format 3, a "compressor" is a codec that takes a bytestream, and returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for Zarr format 3 will be used. @@ -2699,7 +2699,7 @@ def array( List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified). - For Zarr format 3, a "compressor" is a codec that takes a bytestrea, and + For Zarr format 3, a "compressor" is a codec that takes a bytestream, and returns another bytestream. Multiple compressors my be provided for Zarr format 3. If ``filters`` and ``compressors`` are not specified, then the default codecs for Zarr format 3 will be used.