From 6207887d1322bb1052cc29d66a9431145eade77a Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Sun, 5 Dec 2021 15:23:16 +0100 Subject: [PATCH] Fix missing PyArray_DATA accessors This is deprecated in numpy 1.7 --- src/lib/sundials_callbacks.pxi | 6 +++--- thirdparty/hairer/radau5_c_py.pyx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/sundials_callbacks.pxi b/src/lib/sundials_callbacks.pxi index d8e3a920..0a8db24f 100644 --- a/src/lib/sundials_callbacks.pxi +++ b/src/lib/sundials_callbacks.pxi @@ -55,13 +55,13 @@ cdef inline N.ndarray nv2arr(N_Vector v): cdef long int n = (v.content).length cdef realtype* v_data = (v.content).data cdef N.ndarray[realtype, ndim=1, mode='c'] x=N.empty(n) - memcpy(x.data, v_data, n*sizeof(realtype)) + memcpy(PyArray_DATA(x), v_data, n*sizeof(realtype)) return x cdef inline void nv2arr_inplace(N_Vector v, N.ndarray o): cdef long int n = (v.content).length cdef realtype* v_data = (v.content).data - memcpy(o.data, v_data, n*sizeof(realtype)) + memcpy(PyArray_DATA(o), v_data, n*sizeof(realtype)) cdef inline void nv2mat_inplace(int Ns, N_Vector *v, N.ndarray o): cdef long int i,j, Nf @@ -73,5 +73,5 @@ cdef inline void nv2mat_inplace(int Ns, N_Vector *v, N.ndarray o): cdef inline realtype2arr(realtype *data, int n): """Create new numpy array from realtype*""" cdef N.ndarray[realtype, ndim=1, mode='c'] x=N.empty(n) - memcpy(x.data, data, n*sizeof(realtype)) + memcpy(PyArray_DATA(x), data, n*sizeof(realtype)) return x diff --git a/thirdparty/hairer/radau5_c_py.pyx b/thirdparty/hairer/radau5_c_py.pyx index 25d0e66a..efd8c26f 100644 --- a/thirdparty/hairer/radau5_c_py.pyx +++ b/thirdparty/hairer/radau5_c_py.pyx @@ -53,7 +53,7 @@ cdef void c2py(np.ndarray[double, ndim=1, mode='c'] dest, double* source, int di """ Copy (double *) C vector to 1D numpy array """ - memcpy(dest.data, source, dim*sizeof(double)) + memcpy(PyArray_DATA(dest), source, dim*sizeof(double)) @cython.boundscheck(False) @cython.wraparound(False) @@ -61,7 +61,7 @@ cdef void c2py_mat_F(np.ndarray[double, ndim=2, mode='fortran'] dest, double* so """ Copy (double *) C matrix (Fotran-style column major ordering) to 2D numpy array """ - memcpy(dest.data, source, dim*sizeof(double)) + memcpy(PyArray_DATA(dest), source, dim*sizeof(double)) cdef int callback_fcn(integer* n, doublereal* x, doublereal* y_in, doublereal* y_out, doublereal* rpar, integer* ipar, void* fcn_PY):