Numba 无法编译并显示非常奇怪的消息 - 似乎这应该有效?

Numba failing to compile with very strange message - seems like this should work?

我有一个无法使用 Numba 的@njit 装饰器编译的简单函数:

@njit(fastmath=True, nogil=True)
def insert_into_array(array, pos, array_to_insert):
    start = array[0:pos]
    end = array[pos:len(array)]
    inserted = np.concatenate((start, array_to_insert))
    return np.concatenate(inserted, end)

失败并显示此消息:

Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function concatenate at 0x000001E88B04E8B0>) with argument(s) of type(s): (array(uint8, 1d, C), array(uint8, 1d, C))
 * parameterized
In definition 0:
    All templates rejected with literals.
In definition 1:
    All templates rejected without literals.
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function concatenate at 0x000001E88B04E8B0>)

请注意,失败的类型是 (array(uint8, 1d, C), array(uint8, 1d, C)) - 基本上是尝试连接两个简单的一维数组。

由于 NumPy 的 concatenate 函数被 Numba 列为支持的函数,因此我很难理解应该如何解决此问题。

我在 Python 3.7 和 Numba 0.50

关于我做错了什么有什么想法吗?

谢谢!

这看起来像是一个从一开始就被 numba 完全没有好处的函数。无论如何, np.concatenate 的第一个参数应该是一个元组,你不能传递 var args。你的最后一个电话正在尝试。