Skip to content

ak.sum over records? #761

Answered by nsmith-
rkansal47 asked this question in Q&A
Discussion options

You must be logged in to vote

As a workaround for lack of ak.sum support, all the coffea vector objects have a .sum() method. See https://coffeateam.github.io/coffea/api/coffea.nanoevents.methods.vector.LorentzVector.html#coffea.nanoevents.methods.vector.LorentzVector.sum
In your example, however, test_vecs.sum() fails due to #758. For a jagged test_vecs:

>>> test2 = ak.unflatten(test_vecs, [2])
>>> test2.sum()[0]
<LorentzVectorRecord ... y: 0.497, z: 0.503, t: 3.05} type='LorentzVector["x": f...'>
>>> test2.sum()[0].x
2.955137320960509

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by rkansal47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants