1

I'm trying to index a 2D array with another 2D array which works fine in Numpy, but I want to use it in a function decorated with Numba's njit decorator, which gives me this error:

TypingError: No implementation of function Function(<built-in function getitem>) found for signature:
 
getitem(array(float64, 2d, C), array(int32, 2d, C))
 
There are 22 candidate implementations:
      - Of which 20 did not match due to:
      Overload of function 'getitem': File: <numerous>: Line N/A.
        With argument(s): '(array(float64, 2d, C), array(int32, 2d, C))':
       No match.
      - Of which 2 did not match due to:
      Overload in function 'GetItemBuffer.generic': File: numba/core/typing/arraydecl.py: Line 166.
        With argument(s): '(array(float64, 2d, C), array(int32, 2d, C))':
       Rejected as the implementation raised a specific error:
         NumbaTypeError: unsupported array index type array(int32, 2d, C) in [array(int32, 2d, C)]
  raised from /home/martin/anaconda3/envs/scrapyenv/lib/python3.10/site-packages/numba/core/typing/arraydecl.py:72

I've tried to break it down into for loops in a separate function, but keep getting the same error. Is there a simple solution or an easy way to get around this issue?

kynnemall
  • 855
  • 9
  • 26
  • 3
    It looks like it is not supported at first glance. Not all Numpy feature are supported yet (it takes time to implement all the features, not to mention Numpy change over time). Why not using two nested loops? Loops are not a problem with Numba, quite the opposite in fact: creating temporary array tends to be slow so it is better to use loops operating on smaller data when you can. – Jérôme Richard Mar 07 '23 at 00:08

0 Answers0