Why this python class is not working with numba jitclass?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 08:46:24

The issue is with np.round. It's not entirely clear from the documentation, but you can see from looking at the source, that if you are using the function on an array input, you need to provide all 3 arguments. So the following does not work:

nb.jit(nopython=True)
def func(x):
    return np.round(x)

but the following works as expected:

nb.jit(nopython=True)
def func(x):
    out = np.empty_like(x)
    np.round(x, 0, out)
    return out

See the docs for np.around for the full description. I'm going to raise an issue on the numba issue tracker since this isn't obvious from looking at the docs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!