Skip to content

How to use vector in a numba function? #206

Discussion options

You must be logged in to vote

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 +:

      Operator Overload in function 'add': File: unknown: Line unknown.
        With argument(s): '(MomentumObject4DType(AzimuthalObjectRhoPhi(int64 x 2), Longitudina…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ZhenxuanZhang-Jensen
Comment options

@jpivarski
Comment options

@ZhenxuanZhang-Jensen
Comment options

@jpivarski
Comment options

Answer selected by ZhenxuanZhang-Jensen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants