Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Cyclic array? #242

Open
noamzilo opened this issue Apr 7, 2020 · 1 comment
Open

Cyclic array? #242

noamzilo opened this issue Apr 7, 2020 · 1 comment

Comments

@noamzilo
Copy link

noamzilo commented Apr 7, 2020

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

@jpivarski
Copy link
Member

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants