how to understand name a record directly with name of a tuple? #1473
-
Hi, experts |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
>>> import numpy as np
>>> matrix = np.identity(3)
>>> matrix[(0, 1)]
0 Awkward Array extends this to support another kind of structural feature: fields. Awkward Array let's you nest fields, e.g. ak.count(x.y.z) and this is the same as writing ak.count(x[('y', 'z')]) Due to how indexing works, it's also the same if you didn't write any parentheses ak.count(x['y', 'z']) as Python constructs a tuple for the So, to answer your question, events.a.b = ... But due to how Awkward Array works, this won't actually update |
Beta Was this translation helpful? Give feedback.
tuple
keys in NumPy and Awkward usually refer to dimensions, e.g.Awkward Array extends this to support another kind of structural feature: fields. Awkward Array let's you nest fields, e.g.
and this is the same as writing
Due to how indexing works, it's also the same if you didn't write any parentheses
as Python constructs a tuple for the
__getitem__
call.So, to answer your question,
events[("a", "b")] = ...
is setting the fieldb
ofevents.a
(theRecordArray
at fielda
) to a given value. You might think that you can just writeBut due to …