Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Consistent method resolution order (MRO) issue with TLorentzVector #88

Open
PerilousApricot opened this issue Jul 6, 2020 · 3 comments

Comments

@PerilousApricot
Copy link

I'm unsure if this belongs here or perhaps with awkward (though I think it is here).

The following reduced snippet:

import awkward
import uproot_methods
ex = awkward.JaggedArray.fromiter([ [1.0], [2.0, 3.0] ])
p4 = uproot_methods.TLorentzVectorArray.from_ptetaphim(ex, ex, ex, ex)
p4crossp4 = p4.cross(p4)
awkward.topandas(p4crossp4)

Throws

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    awkward.topandas(p4crossp4)
  File "/home/meloam/00-projects/tauid/venv/lib/python3.6/site-packages/awkward/util.py", line 225, in topandas
    return pandas.DataFrame({n: out[n] for n in out.columns}, columns=out.columns)
  File "/home/meloam/00-projects/tauid/venv/lib/python3.6/site-packages/awkward/util.py", line 225, in <dictcomp>
    return pandas.DataFrame({n: out[n] for n in out.columns}, columns=out.columns)
  File "/home/meloam/00-projects/tauid/venv/lib/python3.6/site-packages/awkward/array/jagged.py", line 514, in __getitem__
    cls = awkward.array.objects.Methods.maybemixin(type(content), self.JaggedArray)
  File "/home/meloam/00-projects/tauid/venv/lib/python3.6/site-packages/awkward/array/objects.py", line 29, in maybemixin
    return type(awkwardtype.__name__ + "Methods", allbases, {})
TypeError: Cannot create a consistent method resolution
order (MRO) for bases AwkwardSeries, ExtensionArray, JaggedSeries

with

awkward==0.12.21
awkward-numba==0.12.21
uproot==3.11.7
uproot-methods==0.7.4

There's a couple of different ways to trigger whatever's happening, but they all involve taking the cross product of a TLorentzVector (the same operation with floats succeeds).

@nsmith-
Copy link
Member

nsmith- commented Jul 13, 2020

Seems like the pandas conversion is trying to create a new type that pandas will eat, but messes up.
Depending on the use case, it might be worth moving to awkward1. An early implementation of vector types is now available in coffea.nanoevents.methods. Here's an example:

import awkward1
import coffea.nanoevents.methods  # the import registers the types in awkward1.behavior
ex = awkward1.Array([ [1.0], [2.0, 3.0] ])
p4 = awkward1.zip({"pt": ex, "eta": ex, "phi": ex, "mass": ex}, with_name="PtEtaPhiMLorentzVector")
print(awkward1.pandas.df(p4))
p4c = awkward1.cartesian([p4, p4])
# this should have worked but there seems to be a bug
awkward1.pandas.df(p4c)

@nsmith-
Copy link
Member

nsmith- commented Jul 13, 2020

Made an issue: scikit-hep/awkward#331

@PerilousApricot
Copy link
Author

PerilousApricot commented Jul 13, 2020 via email

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