Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Awkward Records with vector behavior and non-vector coordinates don't work with numba #411

Open
Saransh-cpp opened this issue Jan 22, 2024 · 0 comments
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged

Comments

@Saransh-cpp
Copy link
Member

Vector Version

v1.1.1

Python Version

3.11

OS / Environment

MacOS

Describe the bug

In [1]: import vector; import numba as nb

In [2]: vec = vector.zip({"pt": [1, 2 ,3], "phi": [1, 2, 3], "eta": [1, 2, 3], "
   ...: mass": [1, 2, 3], "charge": [1, 2, 3]})

In [3]: @nb.njit
   ...: def return_charge(vec):
   ...:     return vec.charge

In [4]: return_charge(vec)  # works fine
Out[4]: <Array [1, 2, 3] type='3 * int64'>

In [5]: @nb.njit
   ...: def return_charge(vec):
   ...:     return vec[0].charge 

In [6]: return_charge(vec)  # errors out
---------------------------------------------------------------------------
TypingError                               Traceback (most recent call last)
<ipython-input-8-74cedf343dae> in <cell line: 0>()
----> 1 return_charge(vec)  # errors out

/opt/homebrew/lib/python3.11/site-packages/numba/core/dispatcher.py in _compile_for_args(self, *args, **kws)
    466                 e.patch_message(msg)
    467 
--> 468             error_rewrite(e, 'typing')
    469         except errors.UnsupportedError as e:
    470             # Something unsupported is present in the user code, add help info

/opt/homebrew/lib/python3.11/site-packages/numba/core/dispatcher.py in error_rewrite(e, issue_type)
    407                 raise e
    408             else:
--> 409                 raise e.with_traceback(None)
    410 
    411         argtypes = []

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Unknown attribute 'charge' of type MomentumObject4DType(AzimuthalObjectRhoPhi(int64 x 2), LongitudinalObjectEta(int64 x 1), TemporalObjectTau(int64 x 1))

File "<ipython-input-7-37c9d458f596>", line 3:
def return_charge(vec):
    return vec[0].charge
    ^

During: typing of get attribute at <ipython-input-7-37c9d458f596> (3)

File "<ipython-input-7-37c9d458f596>", line 3:
def return_charge(vec):
    return vec[0].charge
    ^

In [7]: @nb.njit
   ...: def return_charge(vec):
   ...:     return vec.charge[0] 

In [8]: return_charge(vec)  # works fine
Out[8]: 1

Any additional but relevant log output

No response

@Saransh-cpp Saransh-cpp added the bug (unverified) The problem described would be a bug, but needs to be triaged label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant