I have a function that deals with complex data type and I am using numba for faster processing. I declare a zero array using numpy, with complex data type, to be filled in later in the function. But while running numba is not able to overload the zero generating function. To reproduce the error I have provided an MWE.
import numpy as np
from numba import njit
@njit
def my_func(idx):
a = np.zeros((10, 5), dtype=complex)
a[idx] = 10
return a
my_func(4)
The following error is shown where the array a is being initialized.
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<built-in function zeros>) found for signature:
zeros(Tuple(Literal[int](10), Literal[int](5)), dtype=Function(<class 'complex'>))
There are 2 candidate implementations:
Of which 2 did not match due to:
Overload of function 'zeros': File: numba\core\typing\npydecl.py: Line 511.
With argument(s): '(UniTuple(int64 x 2), dtype=Function(<class 'complex'>))':
No match.
I am assuming this has got to do with the data type of the variable a (I need it to be complex). How can I go about this error?
Any help would be appreciated, thanks.
my_funcoperates inplace on an argumenta.numba.complexwithnp.complex64ornp.complex128works, while other choices I tried do not.