I have a sample code that illustrates my issue. If you run:
import numpy as np
from numba import jit
@jit(nopython=True)
def test():
arr = np.array([[[11, 12, 13], [11, 12, 13]], [[21, 22, 23], [21, 22, 23]]])
arr2 = arr[:, 0, :]
arr3 = arr2.argsort()
print(arr3)
test()
It will fail with:
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of BoundFunction(array.argsort for array(int64, 2d, A)) with parameters ()
During: resolving callee type: BoundFunction(array.argsort for array(int64, 2d, A))
During: typing of call at /home/stark/Work/mmr6/test.py (41)
File "test.py", line 41:
def test():
<source elided>
arr3 = arr2.argsort()
^
argsort is supposed to argsort on the last axis. Essentially it should give me:
>>>
[[0 1 2]
[0 1 2]]
I thought copying the arr2 array (with copy()) could solve as it would make the array contiguous in memory (instead of a view), but it fails with the same message except that the type of arr2 in the message is now array(int64, 2d, C) as expected.
Why is it failing and how can I fix it?