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 with view[...], 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)[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. Dask tokenization hashes plain NumPy data or delegates to an explicit source hook; other sources need a naming opt-out or source hook. Lazy views compose shows how the chain stays one description, and where the materialization boundary is.

Learn more