[Numpy-discussion] error: no matching function for call to 'PyArray_DATA'

Jack Howarth howarth.mailing.lists at gmail.com
Thu Dec 11 11:55:31 EST 2014


   Using http://nbviewer.ipython.org/url/refreweb.phys.ethz.ch/hope/notebooks/native_cpp_gen.ipynb
as an example, I have found that the error using
-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION is suppressed with the
change...

--- pymol-1.7.4.0/layer0/Field.cpp.orig 2014-12-11 10:46:41.000000000 -0500
+++ pymol-1.7.4.0/layer0/Field.cpp 2014-12-11 11:52:23.000000000 -0500
@@ -73,7 +73,7 @@

   if(copy) {
     if((result = PyArray_SimpleNew(field->n_dim, dims, typenum)))
-      memcpy(PyArray_DATA(result), field->data, field->size);
+      memcpy(PyArray_DATA((PyArrayObject *)result), field->data, field->size);
   } else {
     result = PyArray_SimpleNewFromData(field->n_dim, dims, typenum,
field->data);
   }

On Thu, Dec 11, 2014 at 11:21 AM, Jack Howarth
<howarth.mailing.lists at gmail.com> wrote:
>    I am trying to patch pymol to avoid the warnings...
>
> /sw/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2:
> warning: "Using deprecated NumPy API, disable it by " "#defining
> NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
> #warning "Using deprecated NumPy API, disable it by " \
>  ^
>
> If I pass the compiler flag
> -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION, the warning becomes an
> error...
>
> # gcc -DNDEBUG -g -fwrapv -fwrapv -O3 -Wall -Wstrict-prototypes
> -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D_PYMOL_LIBPNG
> -D_PYMOL_INLINE -D_PYMOL_OPENGL_SHADERS -D_PYMOL_CGO_DRAWARRAYS
> -D_PYMOL_CGO_DRAWBUFFERS -D_PYMOL_GL_CALLLISTS -D_PYMOL_VMD_PLUGINS
> -D_HAVE_LIBXML -D_PYMOL_FREETYPE -DNO_MMLIBS -D_CGO_DRAWARRAYS
> -DOPENGL_ES_2 -D_PYMOL_NUMPY -Iov/src -Ilayer0 -Ilayer1 -Ilayer2
> -Ilayer3 -Ilayer4 -Ilayer5 -Imodules/cealign/src -Ibuild/generated
> -Icontrib/uiuc/plugins/include
> -Icontrib/uiuc/plugins/molfile_plugin/src
> -I/sw/lib/python2.7/site-packages/numpy/core/include -I/sw/include
> -I/sw/include/freetype2 -I/sw/include/libxml2 -I/usr/include
> -I/usr/include/libxml2 -I/usr/X11/include -I/usr/X11/include/freetype2
> -I/sw/include/python2.7 -c layer0/Field.cpp -o
> build/temp.macosx-10.10-x86_64-2.7/layer0/Field.o
> -Werror=implicit-function-declaration
> -Werror=declaration-after-statement -Wno-write-strings
> -Wno-unused-function -Wno-empty-body -Wno-char-subscripts -ffast-math
> -funroll-loops -O3 -fcommon
>
> layer0/Field.cpp:76:14: error: no matching function for call to 'PyArray_DATA'
>       memcpy(PyArray_DATA(result), field->data, field->size);
>              ^~~~~~~~~~~~
>
> /sw/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1460:1:
> note: candidate function not viable: no known conversion from
> 'PyObject *' (aka '_object *') to
>       'PyArrayObject *' (aka 'tagPyArrayObject *') for 1st argument
> PyArray_DATA(PyArrayObject *arr)
> ^
> 1 error generated.
>
> What is the correct coding to eliminate this error? I have found some
> threads which seems to suggest that PyArray_DATA is still available in
> numpy 1.9 as an inline but I haven't found any examples of projects
> patching their code to convert to that usage.
>           Jack



More information about the NumPy-Discussion mailing list