Skip to content

abczarr.metadata.v3.codecs

Classes

CodecConfig

CodecConfig(*, extra_items: Iterable[tuple[str | bytes, Real | floating | bool | bool | int | str | bytes | Metadata | JsonDict | Iterable[Any] | None]] | Mapping[str | bytes, Real | floating | bool | bool | int | str | bytes | Metadata | JsonDict | Iterable[Any] | None] = FrozenDict({}))

Bases: TypedConfig

This class is the base for a v3 codec's own configuration parameters.

Methods:

Codec

Codec(name: str | bytes = '', configuration: CodecConfig | JsonDict = CodecConfig(extra_items=FrozenDict({})), must_understand: bool | int | str = True)

Bases: Extension

A Codec names a codec through name and carries that codec's own configuration.

Each Codec represents one stage of an array's codec pipeline. See ArrayToArrayCodec, ArrayToBytesCodec and BytesToBytesCodec for what each stage does.

See abczarr.metadata.v2.codecs.base.Codec for a worked example comparing the same codec across the v1, v2 and v3 metadata models.

Attributes

configuration instance-attribute
configuration: CodecConfig

The codec's own parameters.

Methods:

to_json
to_json() -> JsonDict

Serialize this codec to its JSON representation.

A codec with no configuration parameters, such as crc32c or a bytes codec for a single-byte dtype, is written as a bare name, not with an empty configuration object.

Returns:

Type Description
dict

The JSON-compatible representation of this codec.

to_version
to_version(version: ZarrVersion) -> Codec

Convert this codec to another Zarr version.

Parameters:

Name Type Description Default
version ZarrVersion

The target Zarr format version: 1, 2 or 3.

required

Returns:

Type Description
Codec

The equivalent codec for version: this object unchanged for version 3, or the corresponding v1 or v2 codec object otherwise.

Raises:

Type Description
ValueError

If version is not 1, 2 or 3.

ArrayToArrayCodec

ArrayToArrayCodec(name: str | bytes = '', configuration: CodecConfig | JsonDict = CodecConfig(extra_items=FrozenDict({})), must_understand: bool | int | str = True)

Bases: Codec

Transforms an array into another array.

Runs before the pipeline's single array-to-bytes codec, for example by transposing axes, reshaping, or rounding values.

Methods:

ArrayToBytesCodec

ArrayToBytesCodec(name: str | bytes = '', configuration: CodecConfig | JsonDict = CodecConfig(extra_items=FrozenDict({})), must_understand: bool | int | str = True)

Bases: Codec

Serializes an array to bytes, or parses bytes back into an array.

Every codec pipeline has exactly one array-to-bytes codec, forming the boundary between the array-to-array codecs before it and the bytes-to-bytes codecs after.

Methods:

BytesToBytesCodec

BytesToBytesCodec(name: str | bytes = '', configuration: CodecConfig | JsonDict = CodecConfig(extra_items=FrozenDict({})), must_understand: bool | int | str = True)

Bases: Codec

Transforms a byte sequence into another byte sequence.

Runs after the pipeline's array-to-bytes codec. A typical example is a compressor, or a checksum appended for integrity.

Methods:

CompressorCodec

CompressorCodec(name: str | bytes = '', configuration: CodecConfig | JsonDict = CodecConfig(extra_items=FrozenDict({})), must_understand: bool | int | str = True)

Bases: BytesToBytesCodec

This class is the base for a bytes-to-bytes codec that compresses its input.

Methods:

BloscConfig

BloscConfig(cname: Literal['blosclz', 'lz4', 'lz4hc', 'snappy', 'zlib', 'zstd'] = 'lz4', clevel: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] = 5, shuffle: Literal['noshuffle', 'shuffle', 'bitshuffle'] = 'shuffle', blocksize: Integral | integer | bool = 0, typesize: Integral | integer | bool | None = None)

Bases: CodecConfigImpl

Holds the Blosc codec's parameters: compressor, level, shuffle, and block size.

Attributes

cname class-attribute instance-attribute
cname: BloscCodecName = 'lz4'

The inner compressor Blosc applies.

clevel class-attribute instance-attribute
clevel: BloscCompressionLevel = 5

The compression level, from 0 to 9.

shuffle class-attribute instance-attribute
shuffle: BloscShuffle = 'shuffle'

The byte-shuffle filter applied before compression: "noshuffle", "shuffle" or "bitshuffle".

blocksize class-attribute instance-attribute
blocksize: int = 0

The block size Blosc compresses in, in bytes. 0 lets Blosc choose automatically.

typesize class-attribute instance-attribute
typesize: int | None = None

The size, in bytes, of the array's element type. Blosc uses this to group same-position bytes together when shuffling.

Methods:

to_version
to_version(version: ZarrVersion) -> Metadata

Convert this configuration to another Zarr version's Blosc codec.

Parameters:

Name Type Description Default
version ZarrVersion

The target Zarr format version: 1, 2 or 3.

required

Returns:

Type Description
Metadata

The equivalent Blosc codec for version.

Raises:

Type Description
ValueError

If version is not 1, 2 or 3.

BloscCodec

BloscCodec(name: Literal['blosc'] = 'blosc', configuration: BloscConfig | JsonDict | Literal['blosclz', 'lz4', 'lz4hc', 'snappy', 'zlib', 'zstd'] = BloscConfig(cname='lz4', clevel=5, shuffle='shuffle', blocksize=0, typesize=None), must_understand: bool | int | str = True)

Bases: CompressorCodec

Compresses data with Blosc, a meta-compressor that shuffles bytes and then applies an inner compressor.

Blosc groups same-typed bytes together before handing them to cname, then compresses the result in blocks so multiple threads can be used.

Attributes

name instance-attribute
name: Literal['blosc']

Always "blosc".

configuration instance-attribute
configuration: BloscConfig

The codec's parameters.

Methods:

to_version
to_version(version: ZarrVersion) -> Metadata

Convert this codec to another Zarr version.

Parameters:

Name Type Description Default
version ZarrVersion

The target Zarr format version: 1, 2 or 3.

required

Returns:

Type Description
Metadata

The equivalent Blosc codec for version.

BytesConfig

BytesConfig(endian: Literal['big', 'little'] | None = None)

Bases: CodecConfigImpl

Holds the bytes codec's parameters: the byte order to serialize with.

Attributes

endian instance-attribute
endian: Literal['big', 'little'] | None

The byte order to serialize with, "big" or "little", or None for a dtype whose byte order does not matter, such as a single-byte type.

Methods:

BytesCodec

BytesCodec(name: Literal['bytes'] = 'bytes', configuration: BytesConfig | JsonDict | Literal['big', 'little'] | None = BytesConfig(endian=None), must_understand: bool | int | str = True)

Bases: ArrayToBytesCodec

Serializes an array to its raw bytes, in configuration.endian byte order.

This is the plain array-to-bytes codec. It applies no compression and no transform, laying the array's values out contiguously.

Attributes

name instance-attribute
name: Literal['bytes']

Always "bytes".

configuration instance-attribute
configuration: BytesConfig

The codec's parameters.

Methods:

CRC32CConfig

CRC32CConfig()

Bases: CodecConfigImpl

This configuration is empty, since the CRC-32C codec takes no parameters.

Methods:

CRC32CCodec

CRC32CCodec(name: Literal['crc32c'] = 'crc32c', configuration: CRC32CConfig | JsonDict = CRC32CConfig(), must_understand: bool | int | str = True)

Bases: BytesToBytesCodec

Appends a CRC-32C checksum of the preceding bytes, for integrity.

The checksum is verified and stripped on decode, which catches corrupted or truncated chunk data. This codec neither compresses nor transforms the chunk data itself.

Attributes

name instance-attribute
name: Literal['crc32c']

Always "crc32c".

configuration instance-attribute
configuration: CRC32CConfig

The codec's parameters. Always empty.

Methods:

GzipConfig

GzipConfig(level: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] = 5)

Bases: CodecConfigImpl

Holds the gzip codec's parameters: the compression level.

Attributes

level class-attribute instance-attribute
level: GzipCompressionLevel = 5

The compression level, from 0 to 9.

Methods:

GzipCodec

GzipCodec(name: Literal['gzip'] = 'gzip', configuration: GzipConfig | JsonDict | Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] = GzipConfig(level=5), must_understand: bool | int | str = True)

Bases: CompressorCodec

Applies DEFLATE compression (gzip) at a configurable compression level.

Attributes

name instance-attribute
name: Literal['gzip']

Always "gzip".

configuration instance-attribute
configuration: GzipConfig

The codec's parameters.

Methods:

ShardingConfig

ShardingConfig(chunk_shape: Iterable[Integral | integer | bool] = (), codecs: Iterable[Codec | JsonDict | str] = (), index_codecs: Iterable[Codec | JsonDict | str] = (), index_location: Literal['start', 'end'] = 'end')

Bases: CodecConfigImpl

Holds the sharding codec's parameters: the inner chunking and its two codec chains.

Attributes

chunk_shape instance-attribute
chunk_shape: Shape

The shape of the sub-chunks packed into each shard.

codecs instance-attribute
codecs: tuple[Codec, ...]

The codec pipeline that encodes each sub-chunk's data.

index_codecs instance-attribute
index_codecs: tuple[Codec, ...]

The codec pipeline that encodes the index locating each sub-chunk within the shard.

index_location class-attribute instance-attribute
index_location: Literal['start', 'end'] = 'end'

Where the index is stored within the shard: "start" or "end".

Methods:

ShardingCodec

ShardingCodec(name: Literal['sharding_indexed'] = 'sharding_indexed', configuration: ShardingConfig | JsonDict | Shape = ShardingConfig(chunk_shape=(), codecs=(), index_codecs=(), index_location='end'), must_understand: bool | int | str = True)

Bases: ArrayToArrayCodec

Packs many sub-chunks into one storage object, indexed for lookup.

Splits a chunk into smaller sub-chunks, encodes each with its own codec chain, and stores the sub-chunks together in a single shard alongside an index that maps each sub-chunk to its offset and length. Sharding this way reduces the number of files or objects a store holds for arrays with many small chunks.

Attributes

name instance-attribute
name: Literal['sharding_indexed']

Always "sharding_indexed".

configuration instance-attribute
configuration: ShardingConfig

The codec's parameters.

Methods:

TransposeConfig

TransposeConfig(order: Iterable[Integral | integer | bool] = ())

Bases: CodecConfigImpl

Holds the transpose codec's parameters: the permutation of axes to apply.

Attributes

order instance-attribute
order: tuple[int, ...]

The permutation applied to the array's axes.

Methods:

TransposeCodec

TransposeCodec(name: Literal['transpose'] = 'transpose', configuration: TransposeConfig | JsonDict | tuple[int, ...] = TransposeConfig(order=()), must_understand: bool | int | str = True)

Bases: ArrayToArrayCodec

Permutes an array's axes into configuration.order before the rest of the pipeline.

The permutation is reversed on decode, so the array's logical shape is unchanged. It controls the memory layout the later codecs see, for example to make an axis contiguous for a compressor.

Attributes

name instance-attribute
name: Literal['transpose']

Always "transpose".

configuration instance-attribute
configuration: TransposeConfig

The codec's parameters.

Methods:

BitroundConfig

BitroundConfig(keepbits: Integral | integer | bool = 1)

Bases: CodecConfigImpl

Holds the bitround codec's parameters: how many mantissa bits to keep.

Attributes

keepbits class-attribute instance-attribute
keepbits: int = 1

The number of mantissa bits kept. The rest are zeroed.

Methods:

BitroundCodec

BitroundCodec(name: Literal['bitround', 'numcodecs.bitround'] = 'bitround', configuration: BitroundConfig | JsonDict | int = BitroundConfig(keepbits=1), must_understand: bool | int | str = True)

Bases: ArrayToArrayCodec

Rounds a float's mantissa to configuration.keepbits bits, zeroing the rest.

The rounding is lossy and improves the compressibility of floating-point data by discarding low-order precision the data does not need.

Attributes

name instance-attribute
name: Literal['bitround', 'numcodecs.bitround']

Either "bitround" or "numcodecs.bitround".

configuration instance-attribute
configuration: BitroundConfig

The codec's parameters.

Methods:

ScalarMap

ScalarMap(encode: Iterable[tuple[Real | floating | bool | bool | int | str | bytes | None, Real | floating | bool | bool | int | str | bytes | None]] = (), decode: Iterable[tuple[Real | floating | bool | bool | int | str | bytes | None, Real | floating | bool | bool | int | str | bytes | None]] = ())

Bases: Metadata

This class represents an explicit value-to-value mapping used by a cast-value codec.

encode and decode each list (from, to) pairs that map individual values falling outside the ordinary numeric cast. An example is a sentinel value or a small set of categorical codes.

Attributes

encode instance-attribute
encode: _ScalarMap

The (from, to) pairs applied on encode.

decode instance-attribute
decode: _ScalarMap

The (from, to) pairs applied on decode.

Methods:

CastValueConfig

CastValueConfig(data_type: Any, rounding: Literal['nearest-even', 'towards-zero', 'towards-positive', 'towards-negative', 'nearest-away'] = 'nearest-even', out_of_range: Literal['clamp', 'wrap'] | None = None, scalar_map: ScalarMap | JsonDict | tuple[tuple[JsonScalar, JsonScalar], ...] = ScalarMap(encode=(), decode=()))

Bases: CodecConfigImpl

Holds the cast-value codec's parameters: target type, rounding, and value mapping.

Attributes

data_type instance-attribute
data_type: dtype

The dtype values are cast to on encode.

rounding class-attribute instance-attribute
rounding: Literal['nearest-even', 'towards-zero', 'towards-positive', 'towards-negative', 'nearest-away'] = 'nearest-even'

How a value that does not fit data_type exactly is rounded: one of "nearest-even", "towards-zero", "towards-positive", "towards-negative" or "nearest-away".

out_of_range class-attribute instance-attribute
out_of_range: Literal['clamp', 'wrap'] | None = None

How a value outside the range of data_type is handled: "clamp", "wrap", or None for unspecified behavior.

scalar_map instance-attribute
scalar_map: ScalarMap

An explicit mapping for values that need one instead of the ordinary numeric cast.

Methods:

CastValueCodec

CastValueCodec(name: Literal['cast_value'] = 'cast_value', configuration: CastValueConfig | JsonDict | dtype, must_understand: bool | int | str = True)

Bases: ArrayToArrayCodec

Casts an array's values to configuration.data_type, and back on decode.

configuration.rounding and configuration.out_of_range control how a value that does not fit the target type exactly is rounded and clamped or wrapped. configuration.scalar_map maps any values that need an explicit, non-numeric mapping instead.

Attributes

name instance-attribute
name: Literal['cast_value']

Always "cast_value".

configuration instance-attribute
configuration: CastValueConfig

The codec's parameters.

Methods:

ConditionalConfig

ConditionalConfig(codecs: Iterable[Codec | JsonDict | str] = ())

Bases: CodecConfigImpl

Holds the conditional codec's parameters: the candidate codecs to choose among.

Attributes

codecs instance-attribute
codecs: tuple[Codec, ...]

The candidate codecs the conditional codec chooses among.

Methods:

ConditionalCodec

ConditionalCodec(name: Literal['conditional'] = 'conditional', configuration: ConditionalConfig | JsonDict | tuple[Codec, ...] = ConditionalConfig(codecs=()), must_understand: bool | int | str = True)

Bases: Codec

Selects one of several candidate codecs, based on the array to which it is applied.

Lets a single pipeline entry vary by a property of the array, such as its data type, instead of naming one codec unconditionally.

Attributes

name instance-attribute
name: Literal['conditional']

Always "conditional".

configuration instance-attribute
configuration: ConditionalConfig

The codec's parameters.

Methods:

N5DefaultCodecList

N5DefaultCodecList(codecs: Iterable[Codec])

Bases: list

The fixed codec chain of an n5_default codec.

A transpose codec, then a big-endian bytes codec, then any number of trailing codecs. Each element is converted to its concrete codec type on construction. The list holds codec objects, not the raw dicts it was built from.

Parameters:

Name Type Description Default
codecs iterable

The codecs to store, as codec objects or as JSON-like mappings. The first is read as a transpose codec, the second as a big-endian bytes codec, and the rest as arbitrary codecs.

required

Raises:

Type Description
ValueError

If fewer than two codecs are given, or the second codec is little-endian.

Methods:

N5DefaultConfig

N5DefaultConfig(codecs: Iterable[()])

Bases: CodecConfigImpl

Holds the n5_default codec's parameters: the fixed chain of codecs it applies.

Attributes

codecs instance-attribute

The codec chain: a transpose codec, a big-endian bytes codec, then any number of trailing codecs.

Methods:

N5DefaultCodec

N5DefaultCodec(name: Literal['n5_default'] = 'n5_default', configuration: N5DefaultConfig | JsonDict | N5DefaultCodecList, must_understand: bool | int | str = True)

Bases: Codec

Applies the codec chain an N5 array uses by default, for interop with N5.

The chain is fixed to a transpose codec followed by a big-endian bytes codec, with any number of trailing codecs, matching how the N5 format lays out a chunk.

Attributes

name instance-attribute
name: Literal['n5_default']

Always "n5_default".

configuration instance-attribute
configuration: N5DefaultConfig

The codec's parameters.

Methods:

PackBitsConfig

PackBitsConfig(padding_encoding: Literal['first_byte', 'last_byte', 'none'] = 'none', first_bit: Integral | integer | bool | None = None, last_bit: Integral | integer | bool | None = None)

Bases: CodecConfigImpl

Holds the packbits codec's parameters: padding placement and the used bit range.

Attributes

padding_encoding class-attribute instance-attribute
padding_encoding: Literal['first_byte', 'last_byte', 'none'] = 'none'

Where the padding bits sit within the packed bytes: "first_byte", "last_byte" or "none".

first_bit instance-attribute
first_bit: int | None

The index of the first meaningful bit, when padding is present.

last_bit instance-attribute
last_bit: int | None

The index of the last meaningful bit, when padding is present.

Methods:

PackBitsCodec

PackBitsCodec(name: Literal['packbits'] = 'packbits', configuration: PackBitsConfig | JsonDict | Literal['first_byte', 'last_byte', 'none'] = PackBitsConfig(padding_encoding='none', first_bit=None, last_bit=None), must_understand: bool | int | str = True)

Bases: ArrayToBytesCodec

Packs a boolean array down to one bit per element for storage.

Attributes

name instance-attribute
name: Literal['packbits']

Always "packbits".

configuration instance-attribute
configuration: PackBitsConfig

The codec's parameters.

Methods:

ScaleOffsetConfig

ScaleOffsetConfig(offset: Real | floating | bool = 0, scale: Real | floating | bool = 0)

Bases: CodecConfigImpl

Holds the scale-offset codec's parameters: the scale and offset to apply.

Attributes

offset instance-attribute
offset: JsonNumber

The value subtracted before scaling.

scale instance-attribute
scale: JsonNumber

The factor the offset value is multiplied by.

Methods:

ScaleOffsetCodec

ScaleOffsetCodec(name: Literal['scale_offset'] = 'scale_offset', configuration: ScaleOffsetConfig | JsonDict | int | float = ScaleOffsetConfig(offset=0, scale=0), must_understand: bool | int | str = True)

Bases: ArrayToArrayCodec

Quantizes values as (value - offset) * scale, and reverses the transform on decode.

The transform is lossy and useful for storing a bounded floating-point range in fewer bits.

Attributes

name instance-attribute
name: Literal['scale_offset']

Always "scale_offset".

configuration instance-attribute
configuration: ScaleOffsetConfig

The codec's parameters.

Methods:

VLenBytesCodec

VLenBytesCodec(name: Literal['vlen-bytes'] = 'vlen-bytes', configuration: CodecConfig | JsonDict = CodecConfig(extra_items=FrozenDict({})), must_understand: bool | int | str = True)

Bases: ArrayToBytesCodec

Serializes an array of variable-length byte strings to bytes.

Attributes

name instance-attribute
name: Literal['vlen-bytes']

Always "vlen-bytes".

Methods:

VLenUTF8Codec

VLenUTF8Codec(name: Literal['vlen-utf8'] = 'vlen-utf8', configuration: CodecConfig | JsonDict = CodecConfig(extra_items=FrozenDict({})), must_understand: bool | int | str = True)

Bases: ArrayToBytesCodec

Serializes an array of variable-length UTF-8 strings to bytes.

Attributes

name instance-attribute
name: Literal['vlen-utf8']

Always "vlen-utf8".

Methods:

ReshapeConfig

ReshapeConfig(shape: Iterable[Integral | integer | bool | Iterable[Integral | integer | bool]] = ())

Bases: CodecConfigImpl

Holds the reshape codec's parameters: the target shape.

Attributes

shape instance-attribute
shape: tuple[_ReshapeAxis, ...]

The target shape. An axis size of -1 stands for whatever size makes the reshape fit, and a group of sizes splits that axis into several.

Methods:

ReshapeCodec

ReshapeCodec(name: Literal['reshape'] = 'reshape', configuration: ReshapeConfig | JsonDict | tuple[int | tuple[int, ...], ...] = ReshapeConfig(shape=()), must_understand: bool | int | str = True)

Bases: ArrayToArrayCodec

Reshapes an array to configuration.shape before the rest of the pipeline.

The reshape is reversed on decode, so the array's logical shape is unchanged.

Attributes

name instance-attribute
name: Literal['reshape']

Always "reshape".

configuration instance-attribute
configuration: ReshapeConfig

The codec's parameters.

Methods:

ZfpConfig

ZfpConfig(mode: Literal['reversible', 'expert', 'fixed_accuracy', 'fixed_rate', 'fixed_precision'] = 'reversible', minbits: Integral | integer | bool | None = None, maxbits: Integral | integer | bool | None = None, maxprec: Integral | integer | bool | None = None, minexp: Integral | integer | bool | None = None, tolerance: Real | floating | bool | None = None, rate: Real | floating | bool | None = None, precision: Integral | integer | bool | None = None)

Bases: CodecConfigImpl

Holds the ZFP codec's parameters: the mode, and that mode's own parameters.

Only the parameters belonging to mode apply. "expert" takes minbits, maxbits, maxprec and minexp. "fixed_accuracy" takes tolerance. "fixed_rate" takes rate. "fixed_precision" takes precision. "reversible" takes none of them.

Attributes

mode instance-attribute
mode: _ZfpMode

The accuracy mode ZFP compresses in: "reversible", "expert", "fixed_accuracy", "fixed_rate" or "fixed_precision".

minbits class-attribute instance-attribute
minbits: int | None = None

The minimum number of bits per block, in expert mode.

maxbits class-attribute instance-attribute
maxbits: int | None = None

The maximum number of bits per block, in expert mode.

maxprec class-attribute instance-attribute
maxprec: int | None = None

The maximum precision retained, in expert mode.

minexp class-attribute instance-attribute
minexp: int | None = None

The minimum bit-plane coding exponent, in expert mode.

tolerance class-attribute instance-attribute
tolerance: float | None = None

The maximum absolute error allowed, in fixed-accuracy mode.

rate class-attribute instance-attribute
rate: float | None = None

The number of bits per value, in fixed-rate mode.

precision class-attribute instance-attribute
precision: int | None = None

The number of bits of precision retained, in fixed-precision mode.

Methods:

ZfpCodec

ZfpCodec(name: Literal['zfp'] = 'zfp', configuration: ZfpConfig | JsonDict | Literal['reversible', 'expert', 'fixed_accuracy', 'fixed_rate', 'fixed_precision'] = ZfpConfig(mode='reversible', minbits=None, maxbits=None, maxprec=None, minexp=None, tolerance=None, rate=None, precision=None), must_understand: bool | int | str = True)

Bases: ArrayToBytesCodec

Compresses floating-point arrays with ZFP.

configuration.mode selects the accuracy/size trade-off. Compression is lossy, except in "reversible" mode.

Attributes

name instance-attribute
name: Literal['zfp']

Always "zfp".

configuration instance-attribute
configuration: ZfpConfig

The codec's parameters.

Methods:

ZstdConfig

ZstdConfig(level: Integral | integer | bool = 0, checksum: bool | int | str = False)

Bases: CodecConfigImpl

Holds the Zstd codec's parameters: compression level and an optional checksum.

Attributes

level class-attribute instance-attribute
level: int = 0

The compression level. Zstd's levels run from -131072 to 22, wider than the 0-9 range the core compressors use, and negative for the fast modes.

checksum class-attribute instance-attribute
checksum: bool = False

Whether a checksum of each frame is appended for integrity.

Methods:

to_version
to_version(version: ZarrVersion) -> Metadata

Convert this configuration to another Zarr version's Zstd codec.

Parameters:

Name Type Description Default
version ZarrVersion

The target Zarr format version: 1, 2 or 3.

required

Returns:

Type Description
Metadata

The equivalent Zstd codec for version. Only the compression level carries over to v1 and v2, since their numcodecs zstd codec has no checksum option.

Raises:

Type Description
ValueError

If version is not 1, 2 or 3.

ZstdCodec

ZstdCodec(name: Literal['zstd'] = 'zstd', configuration: ZstdConfig | JsonDict | int = ZstdConfig(level=0, checksum=False), must_understand: bool | int | str = True)

Bases: CompressorCodec

Compresses each chunk with Zstandard at a configurable compression level.

configuration.checksum, when set, appends a checksum of each frame for integrity.

Attributes

name instance-attribute
name: Literal['zstd']

Always "zstd".

configuration instance-attribute
configuration: ZstdConfig

The codec's parameters.

Methods:

to_version
to_version(version: ZarrVersion) -> Metadata

Convert this codec to another Zarr version.

Parameters:

Name Type Description Default
version ZarrVersion

The target Zarr format version: 1, 2 or 3.

required

Returns:

Type Description
Metadata

The equivalent Zstd codec for version.