我有这个代码(我的c ++ python模块中的main函数):
static PyObject* FMM(PyObject* self, PyObject* args) { PyObject *model_obj; PyObject *time_obj; PyObject *accepted_obj; PyObject *lat_obj; PyObject *lon_obj; PyObject *h_obj; int N; if (!PyArg_ParseTuple(args, "OOOOOOi", &model_obj, &time_obj, &accepted_obj, &lat_obj, &lon_obj, &h_obj, &N)) { Py_INCREF(Py_None); return Py_None; } PyObject *model = PyArray_FROM_OTF(model_obj, NPY_FLOAT, NPY_INOUT_ARRAY); PyObject *time = PyArray_FROM_OTF(time_obj, NPY_FLOAT, NPY_INOUT_ARRAY); PyObject *accepted = PyArray_FROM_OTF(accepted_obj, NPY_BOOL, NPY_INOUT_ARRAY); PyObject *lat = PyArray_FROM_OTF(lon_obj, NPY_DOUBLE, NPY_INOUT_ARRAY); PyObject *lon = PyArray_FROM_OTF(lon_obj, NPY_DOUBLE, NPY_INOUT_ARRAY); PyObject *h = PyArray_FROM_OTF(h_obj, NPY_DOUBLE, NPY_INOUT_ARRAY); float *MODEL = static_cast(PyArray_DATA(model)); float *TIME = static_cast (PyArray_DATA(time)); bool *ACCEPTED = static_cast (PyArray_DATA(accepted)); double *LAT = static_cast (PyArray_DATA(lat)); double *LON = static_cast (PyArray_DATA(lon)); double *H = static_cast (PyArray_DATA(h)); _FMM(MODEL, TIME, ACCEPTED, LAT, LON, H, N); Py_INCREF(Py_None); return Py_None; }
我一直在警告
#warning "Using deprecated NumPy API,
我想迁移到numpy api 1.7:
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
我应该如何修改我的函数以在新版本的c-api中复制结果?你能指导我做任何一个例子吗?