awkward-0.x icon indicating copy to clipboard operation
awkward-0.x copied to clipboard

Cyclic array?

Open noamzilo opened this issue 4 years ago • 1 comments

I would like to create a bounded, cyclic array. Is that supported? Couldn't find such functionality in the doc.

noamzilo avatar Apr 07 '20 21:04 noamzilo

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.

jpivarski avatar Apr 07 '20 21:04 jpivarski