我正在尝试在内部使用 Numba cfunc
,但是我面临签名匹配问题。如果我将返回类型设置为它识别为好像我设置为或它说。两个签名不能匹配。匹配问题在返回类型中
scipy.LowLevelCallable
ndi.generic_filter
int16
short
int32
intc
long
import numpy as np
import scipy
from numba import cfunc, carray, types
import scipy.ndimage as ndi
@cfunc("intc (CPointer(float64),intp, CPointer(float64), voidptr)") #problematic
def myfunc(values_ptr, len_values, result, data):
#some work here
return 1
footprint = np.array([[0, 1, 0],[1, 1, 1],[0, 1, 0]], dtype=bool)
from scipy import ndimage as ndi
a=np.random.random((100,100))
ndi.generic_filter(a, scipy.LowLevelCallable(myfunc.ctypes), footprint=footprint)
这是错误:
ValueError: Invalid scipy.LowLevelCallable signature "long (double *, long, double *, void *)". Expected one of: ['int (double *, intptr_t, double *, void *)', 'int (double *, npy_intp, double *, void *)', 'int (double *, int, double *, void *)', 'int (double *, long, double *, void *)']
系统规格(如果相关):Python 2.7.10(32 位)、Numba 0.39.0