I'm struggling with a numba error Untyped global name 'is_a_subset': Cannot determine Numba type of <class 'numba.np.ufunc.gufunc.GUFunc'> This usually means I have fumbled and used a method that isn't supported by numba. The following code fails.
@guvectorize("(n),(n)->(n)",nopython=True)
def is_a_subset(x,y,out):
out[:]=np.array([item in x for item in y])
@njit()
def test(x,y,z):
is_a_subset(x,y,z)
return z.mean()
x=np.array([[1,2,3],[3,2,1]])
y=np.array([[3,6,1],[1,2,3]])
z = np.empty_like(x)
test(x,y,z)
However removing njit on the test function makes everything work.
def test(x,y,z):
is_a_subset(x,y,z)
return z.mean()
Why is numba struggling to resolve types when in no-python mode?
I had also tried without different results
@guvectorize(["f8[:],f8[:],f8[:]"],"(n),(n)->(n)",nopython=True)
def is_a_subset(x,y,out):
out[:]=np.array([item in x for item in y])
from guvectorize Not resolving types in nopython mode
No comments:
Post a Comment