I'm unable to get a vectorized ufunc to run. Regular @njit works fine and the @vectorize documentation suggests that the vectorize decorators are the same as njit. I'm running on Windows 10, if that makes a difference
The demo program is as follows. From the output below that we can see that the njit function runs without incident and there's a type error with the vectorized function.
import sys
import numpy
import numba
Structured = numpy.dtype([("a", numpy.int32), ("b", numpy.float64)])
numba_dtype = numba.from_dtype(Structured)
@numba.njit([numba.float64(numba_dtype)])
def jitted(x):
x['b'] = 17.5
return 18.
@numba.vectorize([numba.float64(numba_dtype)], target="cpu", nopython=True)
def vectorized(x):
x['b'] = 17.5
return 12.1
print('python version = ', sys.implementation.version)
print('numpy version = ', numpy.__version__)
print('numba version = ', numba.__version__)
for struct in numpy.empty((3,), dtype=Structured):
print(jitted(struct))
print(vectorized(numpy.empty((3,), dtype=Structured)))
And the output is
python version = sys.version_info(major=3, minor=7, micro=1, releaselevel='final', serial=0)
numpy version = 1.17.3
numba version = 0.48.0
18.0
18.0
18.0
Traceback (most recent call last): File "scratch.py", line 49, in
print(vectorized(numpy.empty((3,), dtype=Structured))) TypeError: ufunc 'vectorized' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
It looks like this is not supported, has been converted to a feature request
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With