Skip to content

registry

zarr.registry

__chunk_key_encoding_registry module-attribute

__chunk_key_encoding_registry: Registry[
    ChunkKeyEncoding
] = Registry()

The registry module is responsible for managing implementations of codecs, pipelines, buffers, ndbuffers, and chunk key encodings and collecting them from entrypoints. The implementation used is determined by the config.

The registry module is also responsible for managing dtypes.

get_numcodec

get_numcodec(data: CodecJSON_V2[str]) -> Numcodec

Resolve a numcodec codec from the numcodecs registry.

This requires the Numcodecs package to be installed.

Parameters:

Returns:

  • codec ( Numcodec ) –

Examples:

>>> codec = get_codec({'id': 'zlib', 'level': 1})
>>> codec
Zlib(level=1)
Source code in zarr/registry.py
def get_numcodec(data: CodecJSON_V2[str]) -> Numcodec:
    """
    Resolve a numcodec codec from the numcodecs registry.

    This requires the Numcodecs package to be installed.

    Parameters
    ----------
    data : CodecJSON_V2
        The JSON metadata for the codec.

    Returns
    -------
    codec : Numcodec

    Examples
    --------

    >>> codec = get_codec({'id': 'zlib', 'level': 1})
    >>> codec
    Zlib(level=1)
    """

    from numcodecs.registry import get_codec

    return get_codec(data)  # type: ignore[no-any-return]