I have a simple function that is failing to compile with Numba's @njit decorator:
@njit(fastmath=True, nogil=True)
def insert_into_array(array, pos, array_to_insert):
start = array[0:pos]
end = array[pos:len(array)]
inserted = np.concatenate((start, array_to_insert))
return np.concatenate(inserted, end)
It's failing with this message:
Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function() with argument(s) of type(s): (array(uint8, 1d, C), array(uint8, 1d, C))
* parameterized
In definition 0:
All templates rejected with literals.
In definition 1:
All templates rejected without literals.
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function()
Note that the types failing on are (array(uint8, 1d, C), array(uint8, 1d, C)) - basically trying to concatenate two simple 1d arrays.
I'm having a lot of trouble understanding what should I do to fix this since NumPy's concatenate function is listed as a supported function by Numba.
I'm on Python 3.7 and Numba 0.50
Any ideas on what am I doing wrong?
Thanks!
解决方案
This looks like a function which does not benefit at all from being numba'd in the first place. Anyway, the first argument to np.concatenate should be a tuple, you cannot pass var args. Your last call is trying that.