Example code with a NumPy ufunc:
import numpy as np
nums = np.array([1, 2, 3])
times = nums.astype('timedelta64[ns]')
np.less(nums, 2)
np.less(nums, np.timedelta64(2))
Both of those give the same result:
array([ True, False, False], dtype=bool)
Now I want to do something similar with Numba:
import numba
@numba.vectorize(nopython=True)
def myless(a, b):
return a < b
myless(nums, 2)
myless(times, np.timedelta64(2)) # fails
The first gives the correct result, but the second fails:
TypeError: ufunc 'myless' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
What's wrong? How can I fix it?