Adopting the example (link) from the documentation, the code:
from numba import guvectorize, int64
@guvectorize([(int64[:], int64, int64[:])], '(n),()->(n)')
def g(x, y, res):
for i in range(x.shape[0]):
res[i] = x[i] + y
@njit
def fun():
a = np.arange(5)
return g(a, 2)
fun()
Produces error:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'g': Cannot determine Numba type of <class 'numpy.ufunc'>
File "<ipython-input-37-02f67c08c51f>", line 4:
def fun():
<source elided>
a = np.arange(5)
return g(a, 2)
^
However, if you comment out the decoration with @njit, fun() returns correctly.
So, the standalone @guvectorize-d function works fine, but doesn't work when it is used inside a function decorated with @njit.
Is this expected behaviour? If not, do you have any ideas about how it can be fixed?
Thanks