A store does not have to target a whole buffer: the destination can be a view of it, a window, a single row, a reshaped or transposed shape. Implement stores through chains of movement ops over a buffer.
apply_stores(shape, data, stores):
data, a flat list of prod(shape) numbers, viewed with the row-major shape.stores is a list of (ops, value) applied in order. ops is a chain of movement ops applied to the buffer's view, in order:
("shrink", offset, size): the window offset .. offset + size - 1 along the leading axis.("index", i): element i of the leading axis; this removes that axis.("reshape", new_shape): the same elements, in row-major order of the current view, laid out in new_shape.("permute", order): reorder the axes.value is a number (written to every element of the view) or a nested list with the view's shape. Write each element into the buffer position the view element refers to.IndexError when a shrink window or an index falls outside the current leading axis.Return (flat, info): flat is the final buffer as a flat list of floats. info has one entry per store: (offset, strides) when the view's buffer positions are exactly for every view index (with stride 0 reported for axes of size 1, and () for a scalar view), otherwise None.