我试图总结它有很多的功能,这样扩展numpy的与用Cython
test.h
void test(int N, int* data_in, int* data_out);
,这样我可以使用那些从numpy的头文件。
现在我有以下用Cython代码:
test.pyx
import numpy as np
cimport numpy as np
ctypedef np.int_t itype_t
cdef extern from 'VolumeForm.h':
void _test 'test' (int, int*, int*)
def wrap_test(np.ndarray[itype_t, ndim=2] data):
cdef np.ndarray[dtype_t, ndim=1] out
out = np.zeros((data.shape[0],1), dtype=np.double)
_test(
data.shape[0],
<itype_t*> data.data,
<itype_t*> out.data
)
return out
然而,当我尝试编译它,我得到的错误:
Error converting Pyrex file to C:
(...)
Cannot assign type 'test.itype_t *' to 'int *'
如何我能解决这个问题吗?