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, which pioneered the approach used here.

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])

Nothing is read until the result() call, however many selections are composed. Lazy views compose shows how the chain stays one description, and where the materialization boundary is.

Learn more