awkward-0.x
awkward-0.x copied to clipboard
Cyclic array?
I would like to create a bounded, cyclic array. Is that supported? Couldn't find such functionality in the doc.
Is the logical length finite or infinite? For infinite lengths, that's something that I hadn't considered; everything must have an int64
length, so it's a non-starter.
Do you mean this?
>>> import awkward1 as ak
>>>
>>> original = ak.Array(np.arange(7) * 1.1)
>>> original
<Array [0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6] type='7 * float64'>
>>>
>>> ak.Array(ak.layout.IndexedArray64(ak.layout.Index64(np.roll(np.arange(7), -2)),
... original.layout))
<Array [2.2, 3.3, 4.4, 5.5, 6.6, 0, 1.1] type='7 * float64'>
The IndexedArray node wraps a view of the data cyclically, and you can change the view in a rather lightweight way (only replacing the IndexedArray node, leaving all the underlying data, which can contain complex records).
But fundamentally, I don't know what it is that you want.