我正在尝试将Numbacfunc用作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
千巷猫影
相关分类