Discussion:
[Numpy-discussion] NPY_DOUBLE not declared
Florian Lindner
2015-08-17 11:11:43 UTC
Permalink
Hello,

I try to converse a piece of C code to the new NumPy API to get rid of the
deprecation warning.

#warning "Using deprecated NumPy API, disable it by " "#defining
NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"

As a first step I replaced arrayobject.h by numpy/npy_math.h:

#include <Python.h>
#include <numpy/npy_math.h>

But this gives errors that NPY_DOUBLE is not declared.

http://docs.scipy.org/doc/numpy/reference/c-api.dtype.html#c.NPY_DOUBLE
gives no information where NPY_DOUBLE is declared, so I used the standard
npy_math.h header.

src/action/PythonAction.cpp:90:51: error: 'NPY_DOUBLE' was not declared in
this scope
PyArray_SimpleNewFromData(1, sourceDim, NPY_DOUBLE,
sourceValues);


Including numpy/npy_common.h does not change it either.

Thanks,
Florian
Sturla Molden
2015-08-17 13:05:42 UTC
Permalink
Why not do as it says instead?


#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION

/* Or: NPY_NO_DEPRECATED_API NPY_API_VERSION */

#include <Python.h>
#include <numpy/arrayobject.h>



Sturla
Post by Florian Lindner
Hello,
I try to converse a piece of C code to the new NumPy API to get rid of the
deprecation warning.
#warning "Using deprecated NumPy API, disable it by " "#defining
NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
#include <Python.h>
#include <numpy/npy_math.h>
But this gives errors that NPY_DOUBLE is not declared.
http://docs.scipy.org/doc/numpy/reference/c-api.dtype.html#c.NPY_DOUBLE
gives no information where NPY_DOUBLE is declared, so I used the standard
npy_math.h header.
src/action/PythonAction.cpp:90:51: error: 'NPY_DOUBLE' was not declared in
this scope
PyArray_SimpleNewFromData(1, sourceDim, NPY_DOUBLE,
sourceValues);
Including numpy/npy_common.h does not change it either.
Thanks,
Florian
Loading...