How to use vector in a numba function? #206
-
just a very simple code to add two jets to form a W boson, if I just use a common function, it can run successfully but it can't be done in Numba: LV_jets = ak.zip({"pt": [1,2,3], "phi": [4,5,6], "eta": [7,8,9], "M": [10,11,12]}, with_name="Momentum4D")
@nb.njit
def SortWithWMass(LV_jets):
print(LV_jets[0] + LV_jets[1])
SortWithWMass(LV_jets) And the bug show this:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hmmm... I just tried this and it worked: >>> import awkward as ak
>>> import numba as nb
>>> LV_jets = ak.zip({"pt": [1,2,3], "phi": [4,5,6], "eta": [7,8,9], "M": [10,11,12]}, with_name="Momentum4D")
>>>
>>> @nb.njit
... def SortWithWMass(LV_jets):
... print(LV_jets[0] + LV_jets[1])
...
>>> SortWithWMass(LV_jets)
vector.obj(pt=2.6760435765272135, phi=-1.603058217614354, eta=7.877655297214794, mass=28.12262855227671) The error message above is saying that it doesn't recognize the objects that are being combined with
and then it desperately tries to figure out why, producing a lot of output in the process. Could you try explicitly registering Awkward Array and Vector with Numba? >>> ak.numba.register()
>>> vector.register_numba() These functions are supposed to be automatically called when |
Beta Was this translation helpful? Give feedback.
Hmmm... I just tried this and it worked:
The error message above is saying that it doesn't recognize the objects that are being combined with
+
: