-
Hi, is it possible to sum over records using ak.sum() while respecting the records' 'add' behaviour? Specifically I'm using the PtEtaPhiMLorentzVector record from Coffea and I am seeing that performing an ak.sum() over an array of of Vectors is not equivalent to summing them manually (i.e. with the '+' operation). e.g. with such an array:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Currently, it is not, though I can see how that would be nice. The reducers (like sum) are handled deep in C++ to make In fact, it might be necessary to prevent It may be possible to get what you want—sums of variable numbers of Lorentz vectors without having to pick out each one—but it's not going to be an easy fix. @nsmith- asked about this a while ago. |
Beta Was this translation helpful? Give feedback.
-
As a workaround for lack of
|
Beta Was this translation helpful? Give feedback.
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.sumIn your example, however,
test_vecs.sum()
fails due to #758. For a jagged test_vecs: