zarr_indexing.composition
zarr_indexing.composition ¶
Composition — chaining two transforms into one.
compose(outer, inner) is the operation that makes views stack. outer maps
user coordinates to intermediate coordinates, inner maps those intermediate
coordinates to storage, and the result maps user coordinates straight to
storage — so a view of a view of an array is still a single
IndexTransform, and indexing never accumulates layers to walk at read time.
Composition works one output map at a time, and each case reduces to substituting the outer map into the inner one:
- A
ConstantMapinner map ignores its input, so it survives unchanged. - A
DimensionMapinner map is affine, so composing it with an outerConstantMaporDimensionMapfolds into newoffset/stridevalues; composing it with an outerArrayMapleaves the index array alone and rescales around it. - An
ArrayMapinner map must be evaluated at the coordinates the outer transform produces, which is the only case that touches array data.
compose ¶
compose(
outer: IndexTransform, inner: IndexTransform
) -> IndexTransform
Compose two IndexTransforms.
outer maps user coords (rank m) to intermediate coords (rank n).
inner maps intermediate coords (rank n) to storage coords (rank p).
The result maps user coords (rank m) to storage coords (rank p).
Precondition: outer.output_rank == inner.domain.ndim.