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

AttributeError: 'CPUDispatcher' object has no attribute '__globals__' with numba.njit decorated function #285

Closed
gatoniel opened this issue Jan 25, 2023 · 1 comment

Comments

@gatoniel
Copy link

Describe the bug
Sorry, for opening a new issue, but the old one was closed due to my late reply and I do not know whether you still get notifications for closed issues. So this is a continuation of: #277 Maybe you can reopen the old issue and close this one or we just continue here.

To Reproduce
With version 3.0.0b2 or the latest master branch run

from typing import TypeVar

import numpy as np
import numpy.typing as npt
from numba import njit
from typeguard import typechecked

T = TypeVar("T", bound=np.generic)


@typechecked
@njit
def numba_sum(
    array: npt.NDArray[T],
) -> T:
    return np.sum(array)

x = np.arange(4)
s = numba_sum.py_func(x)
s = numba_sum(x)

It gives me the following error message:

Traceback (most recent call last):
  File "/home/niklas/drescherlab/merge-stardist-masks/test.py", line 21, in <module>
    s = numba_sum(x)
  File "/home/niklas/.cache/pypoetry/virtualenvs/merge-stardist-masks-Mk5qjuGF-py3.9/lib/python3.9/site-packages/typeguard/__init__.py", line 286, in wrapper
    memo = CallMemo(python_func, _localns, args=args, kwargs=kwargs)
  File "/home/niklas/.cache/pypoetry/virtualenvs/merge-stardist-masks-Mk5qjuGF-py3.9/lib/python3.9/site-packages/typeguard/_memo.py", line 54, in __init__
    super().__init__(func.__globals__, frame_locals, config)
AttributeError: 'CPUDispatcher' object has no attribute '__globals__'

The problem is not with the .py_func but with the real njitted function.

Expected behavior
I expect the call to the njit decorated function to succeed.

Additional context
Copy of #277

@agronholm
Copy link
Owner

Yes, I do get notifications for closed issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants