scikit-hep / uproot3-methods

Pythonic behaviors for non-I/O related ROOT classes.
BSD 3-Clause "New" or "Revised" License
21 stars 28 forks source link

Shortcut multiply and divide for PtEtaPhiMassArrayMethods #71

Closed nsmith- closed 4 years ago

nsmith- commented 4 years ago

Not just for speed, but also because earlier it was doing the wrong thing and multplying eta and phi:

a = uproot_methods.TLorentzVectorArray.from_ptetaphim(
    np.full(10, 20.),
    np.linspace(-5, 5, 10),
    np.linspace(-np.pi, np.pi, 10),
    np.full(10, 20.),
)
a * 500

produced phi values in the thousands!

Also, make the __repr__ a bit more clear.

jpivarski commented 4 years ago

I see—you added a specialization to prevent the wrong thing. (Literal multiplication of all elements? Which would be correct for cartesian but wrong for cylindrical coordinates?)

There isn't a test here, but do I have your word that you've tested it? :)

nsmith- commented 4 years ago

I'll add some tests

jpivarski commented 4 years ago

Thank you!

jpivarski commented 4 years ago

And ping me when you're done so that I don't forget to merge it.

nsmith- commented 4 years ago

@jpivarski all good