【发布时间】:2020-04-23 08:29:49
【问题描述】:
如果我定义
import numba as nb
import numpy as np
@nb.vectorize
def nb_vec(x):
if x>0:
x=x+100
return x
然后
x=np.random.random(1000000)
nb_vec(x)
运行没有问题
但是如果我添加像这样的目标选项
@nb.vectorize(target='parallel')
def nb_vec(x):
if x>0:
x=x+100
return x
然后
x=np.random.random(1000000)
nb_vec(x)
输出错误信息
----------------------------------------------- ---------------------------- TypeError Traceback(最近一次调用 最后)在 1 x=np.random.random(1000000) ----> 2 nb_vec(x)
TypeError: ufunc 'nb_vec' 不支持输入类型,并且 输入无法安全地强制转换为任何支持的类型 强制转换规则“安全”
怎么了?
【问题讨论】: