当我在我的函数中比较两个 numpy 数组时,我收到一个错误,说只有长度为 1 的数组可以转换为 Python 标量:
from numpy.random import rand
from numba import autojit
@autojit
def myFun():
a = rand(10,1)
b = rand(10,1)
idx = a > b
return idx
myFun()
错误:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-f7b68c0872a3> in <module>()
----> 1 myFun()
/Users/Guest/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numba/numbawrapper.so in numba.numbawrapper._NumbaSpecializingWrapper.__call__ (numba/numbawrapper.c:3764)()
TypeError: only length-1 arrays can be converted to Python scalars