Skip to content

zarr_indexing.grid

zarr_indexing.grid

Structural typing for the chunk-grid surface used by chunk resolution.

chunk_resolution needs only a narrow slice of a chunk grid: the per-dimension mapping between storage indices and chunk coordinates, passed as one DimensionGridLike per storage dimension. Rather than import zarr's concrete grid types, we type against this Protocol; zarr's per-dimension grids satisfy it structurally, so no zarr import is needed here.

DimensionGridLike

Bases: Protocol

The per-dimension chunk-mapping surface consumed by chunk resolution.

Source code in packages/zarr-indexing/src/zarr_indexing/grid.py
class DimensionGridLike(Protocol):
    """The per-dimension chunk-mapping surface consumed by chunk resolution."""

    def index_to_chunk(self, idx: int) -> int: ...
    def chunk_offset(self, chunk_ix: int) -> int: ...
    def chunk_size(self, chunk_ix: int) -> int: ...
    def indices_to_chunks(self, indices: npt.NDArray[np.intp]) -> npt.NDArray[np.intp]: ...

chunk_offset

chunk_offset(chunk_ix: int) -> int
Source code in packages/zarr-indexing/src/zarr_indexing/grid.py
def chunk_offset(self, chunk_ix: int) -> int: ...

chunk_size

chunk_size(chunk_ix: int) -> int
Source code in packages/zarr-indexing/src/zarr_indexing/grid.py
def chunk_size(self, chunk_ix: int) -> int: ...

index_to_chunk

index_to_chunk(idx: int) -> int
Source code in packages/zarr-indexing/src/zarr_indexing/grid.py
def index_to_chunk(self, idx: int) -> int: ...

indices_to_chunks

indices_to_chunks(indices: NDArray[intp]) -> NDArray[intp]
Source code in packages/zarr-indexing/src/zarr_indexing/grid.py
def indices_to_chunks(self, indices: npt.NDArray[np.intp]) -> npt.NDArray[np.intp]: ...