Argwhere problem

1 import numpy as np
2 from numba import njit,jit
3
4 @njit
5 def gpuu(x,y):
6 return np.argwhere((x==y))
7
8
9 a = np.array(range(10000))
10 gpuu(50000,a)
11
~
~
create the following error

Traceback (most recent call last):
File “gpu.py”, line 10, in
gpuu(50000,a)
File “/usr/lib/python3/dist-packages/numba/dispatcher.py”, line 348, in _compile_for_args
error_rewrite(e, ‘typing’)
File “/usr/lib/python3/dist-packages/numba/dispatcher.py”, line 315, in error_rewrite
reraise(type(e), e, None)
File “/usr/lib/python3/dist-packages/numba/six.py”, line 658, in reraise
raise value.with_traceback(tb)
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Use of unsupported NumPy function ‘numpy.argwhere’ or unsupported use of the function.

File “gpu.py”, line 6:
def gpuu(x,y):
return np.argwhere((x==y))
^

[1] During: typing of get attribute at gpu.py (6)

File “gpu.py”, line 6:
def gpuu(x,y):
return np.argwhere((x==y))
^

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:

and

For more information about typing errors and how to debug them visit:

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:

can you assist ?

Hey,

What version of Numba are you using? I can’t replicate your result with Numba version 0.54.1.

Using:

from numba import njit
import numpy as np

@njit
def numba_argwhere(x, y):
    return np.argwhere(x==y)

def numpy_argwhere(x, y):
    return np.argwhere(x==y)

x = np.array(range(10000))
y = np.random.randint(x.size)

nb_res = numba_argwhere(x, y)
np_res = numpy_argwhere(x, y)

assert np.allclose(np_res, nb_res)

Regards,
Rutger

1 Like

my version is:
0.42.0

Hi @queency

In that case please try updating your numba installation, that version is almost 3 years old at this point, and there are improvements and new features added to numba all the time.

Can you direct me with upgrading numba ?
Is there an easy way to upgrade via repository (numba only upgrade)
Should i use the egg file or should i just download that latest and put the directory in position?

That depends a lot on your particular setup, but unless you are on some very obscure system, numba can be updated like any other python package.

If you don’t know how to do that, then I suggest you ping me (@HPLegion) on numba’s gitter channel (numba/numba - Gitter) and I can try to talk you through it. Gitter is better suited for quick step by step messages.