Skip to content

zarr-indexing

This library is for modelling and transforming NumPy-style array indexing expressions. It separates the declaration of an array indexing expression from the result of that expression.

Developed for use in zarr.

Inspired by TensorStore's index-transform model.

Install

zarr-indexing is developed in the zarr-python repository and released independently of zarr itself:

pip install zarr-indexing

Quickstart

Wrap an array, compose a lazy view through .lazy, and call result() when you want its values:

import numpy as np

from zarr_indexing import LazyArray

source = np.array([10, 11, 12, 13, 14, 15])
view = LazyArray.from_numpy(source).lazy[2:5]

view.result()
# array([12, 13, 14])

Composing these selections does not read source values; the example reads them at result(). Construction inspects source metadata, and Dask tokenization can inspect source values. Lazy views compose shows how the chain stays one description, and where the materialization boundary is.

Learn more