I have two simple and similar functions. One can compile with numba while the other can't. I can't understand the difference between them.The following are these two functions:
The first one:
@nb.njit(float64[:](float64[:], float64[:]))
def arrAdd(a,b):
assert a.shape == b.shape
return a + b
It succeed in compiling. When I call it,
arrAdd(np.array([1,2.0,21]),np.array([2,3.0,1]))
It will return:
array([ 3., 5., 22.])
The second one:
c = np.array([1,2.0,21])
@nb.njit
def arrAdd1(arr):
return arrAdd(arr,c)
However, when I call this function:
arrAdd1([2,3.0,1])
it will show:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of type(CPUDispatcher(<function arrAdd at 0x00000212A9FDC670>)) with parameters (array(float64, 1d, C), readonly array(float64, 1d, C))
Known signatures:
* (array(float64, 1d, A), array(float64, 1d, A)) -> array(float64, 1d, A)
During: resolving callee type: type(CPUDispatcher(<function arrAdd at 0x00000212A9FDC670>))
During: typing of call at <ipython-input-57-c77e552c5560> (4)
File "<ipython-input-57-c77e552c5560>", line 4:
def arrAdd1(arr):
return arrAdd(arr, c)
^
So what's the difference between array(float64, 1d, C)) and array(float64, 1d, A)?