具有复杂numpy数组和本机数据类型的numbaTypingError

我有一个处理复杂数据类型的函数,我正在使用它numba来加快处理速度。我声明了一个零数组numpy,使用复杂数据类型,稍后在函数中填充。但在运行时numba不能使零发生函数过载。为了重现错误,我提供了一个 MWE。

import numpy as np
from numba import njit

@njit
def my_func(idx):
    a = np.zeros((10, 5), dtype=complex)
    a[idx] = 10
    return a

my_func(4)

以下错误显示在a初始化数组的位置。

numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)

No implementation of function Function(<built-in function zeros>) found for signature:
zeros(Tuple(Literal[int](10), Literal[int](5)), dtype=Function(<class 'complex'>))
There are 2 candidate implementations:

 Of which 2 did not match due to:
  Overload of function 'zeros': File: numbacoretypingnpydecl.py: Line 511.
    With argument(s): '(UniTuple(int64 x 2), dtype=Function(<class 'complex'>))':
   No match.

我假设这与变量的数据类型有关a(我需要它很复杂)。我该如何解决这个错误?

任何帮助将不胜感激,谢谢。

以上是具有复杂numpy数组和本机数据类型的numbaTypingError的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>