zarr.codecs#
Submodules#
Classes#
Enum for compression library used by blosc. |
|
Base class for bytes-to-bytes codecs. |
|
Enum for shuffle filter used by blosc. |
|
Base class for array-to-bytes codecs. |
|
Base class for bytes-to-bytes codecs. |
|
Enum for endian type used by bytes codec. |
|
Base class for bytes-to-bytes codecs. |
|
Base class for array-to-bytes codecs. |
|
Enum for index location used by the sharding codec. |
|
Base class for array-to-array codecs. |
|
Base class for array-to-bytes codecs. |
|
Base class for array-to-bytes codecs. |
|
Base class for bytes-to-bytes codecs. |
Package Contents#
- class zarr.codecs.BloscCname(*args, **kwds)[source]#
Bases:
enum.Enum
Enum for compression library used by blosc.
- blosclz = 'blosclz'#
- lz4 = 'lz4'#
- lz4hc = 'lz4hc'#
- snappy = 'snappy'#
- zlib = 'zlib'#
- zstd = 'zstd'#
- class zarr.codecs.BloscCodec(
- *,
- typesize: int | None = None,
- cname: BloscCname | str = BloscCname.zstd,
- clevel: int = 5,
- shuffle: BloscShuffle | str | None = None,
- blocksize: int = 0,
Bases:
zarr.abc.codec.BytesBytesCodec
Base class for bytes-to-bytes codecs.
- abstract compute_encoded_size(
- _input_byte_length: int,
- _chunk_spec: zarr.core.array_spec.ArraySpec,
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
- evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self [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 [source]#
Create an instance of the model from a dictionary
- to_dict() dict[str, zarr.core.common.JSON] [source]#
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.
- cname: BloscCname#
- is_fixed_size = False#
- shuffle: BloscShuffle | None#
- class zarr.codecs.BloscShuffle(*args, **kwds)[source]#
Bases:
enum.Enum
Enum for shuffle filter used by blosc.
- classmethod from_int(num: int) BloscShuffle [source]#
- bitshuffle = 'bitshuffle'#
- noshuffle = 'noshuffle'#
- shuffle = 'shuffle'#
- class zarr.codecs.BytesCodec(*, endian: Endian | str | None = default_system_endian)[source]#
Bases:
zarr.abc.codec.ArrayBytesCodec
Base class for array-to-bytes codecs.
- compute_encoded_size(
- input_byte_length: int,
- _chunk_spec: zarr.core.array_spec.ArraySpec,
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
- evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self [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 [source]#
Create an instance of the model from a dictionary
- to_dict() dict[str, zarr.core.common.JSON] [source]#
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.
- is_fixed_size = True#
- class zarr.codecs.Crc32cCodec[source]#
Bases:
zarr.abc.codec.BytesBytesCodec
Base class for bytes-to-bytes codecs.
- compute_encoded_size(
- input_byte_length: int,
- _chunk_spec: zarr.core.array_spec.ArraySpec,
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
- classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self [source]#
Create an instance of the model from a dictionary
- to_dict() dict[str, zarr.core.common.JSON] [source]#
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.
- is_fixed_size = True#
- class zarr.codecs.Endian(*args, **kwds)[source]#
Bases:
enum.Enum
Enum for endian type used by bytes codec.
- big = 'big'#
- little = 'little'#
- class zarr.codecs.GzipCodec(*, level: int = 5)[source]#
Bases:
zarr.abc.codec.BytesBytesCodec
Base class for bytes-to-bytes codecs.
- abstract compute_encoded_size(
- _input_byte_length: int,
- _chunk_spec: zarr.core.array_spec.ArraySpec,
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
- classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self [source]#
Create an instance of the model from a dictionary
- to_dict() dict[str, zarr.core.common.JSON] [source]#
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.
- is_fixed_size = False#
- class zarr.codecs.ShardingCodec(
- *,
- chunk_shape: zarr.core.common.ChunkCoordsLike,
- codecs: collections.abc.Iterable[zarr.abc.codec.Codec | dict[str, zarr.core.common.JSON]] = (BytesCodec(),),
- index_codecs: collections.abc.Iterable[zarr.abc.codec.Codec | dict[str, zarr.core.common.JSON]] = (BytesCodec(), Crc32cCodec()),
- index_location: ShardingCodecIndexLocation | str = ShardingCodecIndexLocation.end,
Bases:
zarr.abc.codec.ArrayBytesCodec
,zarr.abc.codec.ArrayBytesCodecPartialDecodeMixin
,zarr.abc.codec.ArrayBytesCodecPartialEncodeMixin
Base class for array-to-bytes codecs.
- compute_encoded_size(
- input_byte_length: int,
- shard_spec: zarr.core.array_spec.ArraySpec,
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
- evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self [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 [source]#
Create an instance of the model from a dictionary
- to_dict() dict[str, zarr.core.common.JSON] [source]#
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: zarr.core.common.ChunkCoords,
- dtype: numpy.dtype[Any],
- chunk_grid: zarr.core.chunk_grids.ChunkGrid,
Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.
- Parameters:
- shapeChunkCoords
The array shape
- dtypenp.dtype[Any]
The array data type
- chunk_gridChunkGrid
The array chunk grid
- chunk_shape: zarr.core.common.ChunkCoords#
- property codec_pipeline: zarr.abc.codec.CodecPipeline#
- index_location: ShardingCodecIndexLocation#
- class zarr.codecs.ShardingCodecIndexLocation(*args, **kwds)[source]#
Bases:
enum.Enum
Enum for index location used by the sharding codec.
- end = 'end'#
- start = 'start'#
- class zarr.codecs.TransposeCodec(*, order: zarr.core.common.ChunkCoordsLike)[source]#
Bases:
zarr.abc.codec.ArrayArrayCodec
Base class for array-to-array codecs.
- compute_encoded_size(
- input_byte_length: int,
- _chunk_spec: zarr.core.array_spec.ArraySpec,
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
- evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self [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 [source]#
Create an instance of the model from a dictionary
- resolve_metadata(
- chunk_spec: 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] [source]#
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: numpy.dtype[Any],
- chunk_grid: zarr.core.chunk_grids.ChunkGrid,
Validates that the codec configuration is compatible with the array metadata. Raises errors when the codec configuration is not compatible.
- Parameters:
- shapeChunkCoords
The array shape
- dtypenp.dtype[Any]
The array data type
- chunk_gridChunkGrid
The array chunk grid
- is_fixed_size = True#
- class zarr.codecs.VLenBytesCodec[source]#
Bases:
zarr.abc.codec.ArrayBytesCodec
Base class for array-to-bytes codecs.
- abstract compute_encoded_size(
- input_byte_length: int,
- _chunk_spec: zarr.core.array_spec.ArraySpec,
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
- evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self [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 [source]#
Create an instance of the model from a dictionary
- to_dict() dict[str, zarr.core.common.JSON] [source]#
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.
- class zarr.codecs.VLenUTF8Codec[source]#
Bases:
zarr.abc.codec.ArrayBytesCodec
Base class for array-to-bytes codecs.
- abstract compute_encoded_size(
- input_byte_length: int,
- _chunk_spec: zarr.core.array_spec.ArraySpec,
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
- evolve_from_array_spec(array_spec: zarr.core.array_spec.ArraySpec) Self [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 [source]#
Create an instance of the model from a dictionary
- to_dict() dict[str, zarr.core.common.JSON] [source]#
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.
- class zarr.codecs.ZstdCodec(*, level: int = 0, checksum: bool = False)[source]#
Bases:
zarr.abc.codec.BytesBytesCodec
Base class for bytes-to-bytes codecs.
- abstract compute_encoded_size(
- _input_byte_length: int,
- _chunk_spec: zarr.core.array_spec.ArraySpec,
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
- classmethod from_dict(data: dict[str, zarr.core.common.JSON]) Self [source]#
Create an instance of the model from a dictionary
- to_dict() dict[str, zarr.core.common.JSON] [source]#
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.
- is_fixed_size = True#