Skip to content

ChunkGrid

zarrista.ChunkGrid

The chunk grid of an array.

The chunk grid shows how the array shape divides into chunks.

array_shape property

array_shape: list[int]

The shape of the array, in elements along each dimension.

grid_shape property

grid_shape: list[int]

The shape of the grid, in number of chunks along each dimension.

metadata property

The chunk grid's Zarr v3 metadata.

ndim property

ndim: int

The number of dimensions.

from_metadata staticmethod

from_metadata(
    metadata: ZarrV3NamedConfigJSON, shape: Sequence[int]
) -> ChunkGrid

Construct a chunk grid from its Zarr v3 metadata and the array shape.

Parameters:

  • metadata (ZarrV3NamedConfigJSON) –

    The Zarr v3 metadata of the chunk grid.

  • shape (Sequence[int]) –

    The shape of the array, in elements along each dimension.

Returns:

Raises:

  • PluginCreateError

    If the metadata names an unsupported chunk grid, or if the metadata is not compatible with shape.

rectilinear staticmethod

rectilinear(
    array_shape: Sequence[int], *, chunk_shapes: Sequence[ChunkEdgeLengths]
) -> ChunkGrid

Construct a rectilinear grid with different chunk sizes along each dimension.

Parameters:

  • array_shape (Sequence[int]) –

    The shape of the array, in elements along each dimension.

  • chunk_shapes (Sequence[ChunkEdgeLengths]) –

    The chunk sizes along each dimension.

Returns:

Raises:

regular staticmethod

regular(array_shape: Sequence[int], *, chunk_shape: Sequence[int]) -> ChunkGrid

Construct a regular grid with a fixed chunk shape.

Parameters:

  • array_shape (Sequence[int]) –

    The shape of the array, in elements along each dimension.

  • chunk_shape (Sequence[int]) –

    The shape of each chunk, in elements along each dimension.

Returns:

Raises:

regular_bounded staticmethod

regular_bounded(
    array_shape: Sequence[int], *, chunk_shape: Sequence[int]
) -> ChunkGrid

Construct a regular grid that clips the last chunks to the array bounds.

This chunk grid is experimental. Other Zarr V3 implementations can be incompatible with it.

Parameters:

  • array_shape (Sequence[int]) –

    The shape of the array, in elements along each dimension.

  • chunk_shape (Sequence[int]) –

    The maximum shape of a chunk, in elements along each dimension. The grid clips the chunks at the array bounds to a smaller shape.

Returns:

Raises:

zarrista.ChunkKeyEncoding

How an array maps chunk grid indices to store keys.

metadata property

The chunk key encoding's Zarr v3 metadata.

name property

name: str | None

The chunk key encoding's Zarr v3 name (e.g. "default"), if any.

default staticmethod

default(sep: Literal['.', '/']) -> ChunkKeyEncoding

Construct the default chunk key encoding with the given separator.

Parameters:

  • sep (Literal['.', '/']) –

    The separator between the parts of a chunk key.

Returns:

Raises:

from_metadata staticmethod

from_metadata(metadata: ZarrV3NamedConfigJSON) -> ChunkKeyEncoding

Construct a chunk key encoding from its Zarr v3 metadata.

Parameters:

Returns:

Raises:

  • PluginCreateError

    If the metadata names an unsupported chunk key encoding, or if the configuration is not valid for it.

Types

zarrista._chunks.ChunkEdgeLengths module-attribute

ChunkEdgeLengths: TypeAlias = int | Sequence[RunLength]

The chunk sizes along one dimension.

An integer if the dimension has one chunk size, or a sequence of runs if the chunk sizes change along the dimension.

zarrista._chunks.RunLength module-attribute

RunLength: TypeAlias = int | tuple[int, int]

One run of chunks along a rectilinear chunk edge.

A single chunk size, or a (size, count) pair. The pair means count adjacent chunks that each have the given size.