Composable, lazy coordinate transforms for Zarr array indexing.
This package implements TensorStore-inspired index transforms. The core idea:
each supported indexing operation (slicing, fancy indexing, etc.) produces a coordinate
mapping from user space to storage space. These mappings compose without reading selected source values. LazyArray
materializes them on request; the transform algebra itself performs no source I/O.
Key types:
LazyArray— wraps a system-memory/basic-indexing source with lazy indexing:LazyArray.from_numpy(numpy_array)[10:50, ::2].oindex[[3, 1, 1], :]. The key's type picks the frame: NumPy keys are positions relative to the view, while anIndexDomainorIndexTransformkey addresses the view's absolute domain, which every view keeps. composes a transform and returns a new view without reading data, andresult()materializes it into owned system memory.LazyArray(source)uses the basic reader;from_numpyselectsnumpy_reader, which currently uses the same slab-and-gather implementation. Device sources that refuse NumPy conversion need a custom reader to transfer values into the output buffer.Reader— the explicit backend execution boundary: transforms say which values belong in the result, while readers say how a backend obtains themIndexDomain— a rectangular region of integer coordinatesIndexTransform— maps input coordinates to storage coordinatesChunkPlanandChunkProjection— lazily partition a selection over a caller-selected grid and pair each chunk-local transform with its placement in the request, without binding a storage backend or schedulerGridPartition— the plan's factored, columnar form: one table per axis (StridedSet,IndexedSet) plusjoint_setsfor connected index-array components, from which projections are derived on demandConstantMap,DimensionMap,ArrayMap— the three ways a single output dimension can depend on the inputcompose— chain two transforms into one
The base package depends on NumPy and the standard library; its optional testing
module also requires Hypothesis. The package does not import zarr. It is developed
in the zarr-python repository,
and its examples include reading Zarr arrays through Dask. Installing it does not
replace Zarr's indexing implementation.
pip install zarr-indexingDevelopment commands, the test suite and the docs build are described in CONTRIBUTING.md in the repository. Issues and pull requests go to zarr-developers/zarr-python.