zarr.codecs.numcodecs#

Classes#

Adler32

Base class for bytes-to-bytes codecs.

AsType

Base class for array-to-array codecs.

BZ2

Base class for bytes-to-bytes codecs.

BitRound

Base class for array-to-array codecs.

Blosc

Base class for bytes-to-bytes codecs.

CRC32

Base class for bytes-to-bytes codecs.

CRC32C

Base class for bytes-to-bytes codecs.

Delta

Base class for array-to-array codecs.

FixedScaleOffset

Base class for array-to-array codecs.

Fletcher32

Base class for bytes-to-bytes codecs.

GZip

Base class for bytes-to-bytes codecs.

JenkinsLookup3

Base class for bytes-to-bytes codecs.

LZ4

Base class for bytes-to-bytes codecs.

LZMA

Base class for bytes-to-bytes codecs.

PCodec

Base class for array-to-bytes codecs.

PackBits

Base class for array-to-array codecs.

Quantize

Base class for array-to-array codecs.

Shuffle

Base class for bytes-to-bytes codecs.

ZFPY

Base class for array-to-bytes codecs.

Zlib

Base class for bytes-to-bytes codecs.

Zstd

Base class for bytes-to-bytes codecs.

Package Contents#

class zarr.codecs.numcodecs.Adler32(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsChecksumCodec

Base class for bytes-to-bytes codecs.

compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.AsType(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsArrayArrayCodec

Base class for array-to-array codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) AsType[source]#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec[source]#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.BZ2(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsBytesBytesCodec

Base class for bytes-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.BitRound(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsArrayArrayCodec

Base class for array-to-array codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.Blosc(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsBytesBytesCodec

Base class for bytes-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.CRC32(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsChecksumCodec

Base class for bytes-to-bytes codecs.

compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.CRC32C(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsChecksumCodec

Base class for bytes-to-bytes codecs.

compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.Delta(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsArrayArrayCodec

Base class for array-to-array codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec[source]#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.FixedScaleOffset(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsArrayArrayCodec

Base class for array-to-array codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(
array_spec: zarr.core.array_spec.ArraySpec,
) FixedScaleOffset[source]#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec[source]#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.Fletcher32(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsChecksumCodec

Base class for bytes-to-bytes codecs.

compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.GZip(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsBytesBytesCodec

Base class for bytes-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.JenkinsLookup3(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsChecksumCodec

Base class for bytes-to-bytes codecs.

compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.LZ4(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsBytesBytesCodec

Base class for bytes-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.LZMA(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsBytesBytesCodec

Base class for bytes-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.PCodec(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsArrayBytesCodec

Base class for array-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.PackBits(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsArrayArrayCodec

Base class for array-to-array codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec[source]#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(*, dtype: zarr.dtype.ZDType[Any, Any], **_kwargs: Any) None[source]#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.Quantize(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsArrayArrayCodec

Base class for array-to-array codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Quantize[source]#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.Shuffle(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsBytesBytesCodec

Base class for bytes-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Shuffle[source]#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.ZFPY(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsArrayBytesCodec

Base class for array-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.Zlib(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsBytesBytesCodec

Base class for bytes-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#
class zarr.codecs.numcodecs.Zstd(**codec_config: zarr.core.common.JSON)[source]#

Bases: _NumcodecsBytesBytesCodec

Base class for bytes-to-bytes codecs.

abstractmethod compute_encoded_size(
input_byte_length: int,
chunk_spec: zarr.core.array_spec.ArraySpec,
) int#

Given an input byte length, this method returns the output byte length. Raises a NotImplementedError for codecs with variable-sized outputs (e.g. compressors).

Parameters:
input_byte_lengthint
chunk_specArraySpec
Returns:
int
async decode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecOutput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecInput | None]#

Decodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecOutput | None, ArraySpec]]

Ordered set of encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecInput | None]
async encode(
chunks_and_specs: collections.abc.Iterable[tuple[CodecInput | None, zarr.core.array_spec.ArraySpec]],
) collections.abc.Iterable[CodecOutput | None]#

Encodes a batch of chunks. Chunks can be None in which case they are ignored by the codec.

Parameters:
chunks_and_specsIterable[tuple[CodecInput | None, ArraySpec]]

Ordered set of to-be-encoded chunks with their accompanying chunk spec.

Returns:
Iterable[CodecOutput | None]
evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self#

Fills in codec configuration parameters that can be automatically inferred from the array metadata.

Parameters:
array_specArraySpec
Returns:
Self
classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self#

Create an instance of the model from a dictionary

resolve_metadata(
chunk_spec: zarr.core.array_spec.ArraySpec,
) zarr.core.array_spec.ArraySpec#

Computed the spec of the chunk after it has been encoded by the codec. This is important for codecs that change the shape, data type or fill value of a chunk. The spec will then be used for subsequent codecs in the pipeline.

Parameters:
chunk_specArraySpec
Returns:
ArraySpec
to_dict() dict[str, zarr.core.common.JSON]#

Recursively serialize this model to a dictionary. This method inspects the fields of self and calls x.to_dict() for any fields that are instances of Metadata. Sequences of Metadata are similarly recursed into, and the output of that recursion is collected in a list.

validate(
*,
shape: tuple[int, Ellipsis],
dtype: zarr.core.dtype.wrapper.ZDType[zarr.core.dtype.wrapper.TBaseDType, zarr.core.dtype.wrapper.TBaseScalar],
chunk_grid: zarr.core.chunk_grids.ChunkGrid,
) None#

Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.

Parameters:
shapetuple[int, …]

The array shape

dtypenp.dtype[Any]

The array data type

chunk_gridChunkGrid

The array chunk grid

codec_config: dict[str, zarr.core.common.JSON]#
codec_name: str#
is_fixed_size: bool#