[Python] Is there any problem using deprecated NumPy API?

Discussão em 'Python' iniciado por Stack, Março 29, 2025.

  1. Stack

    Stack Membro Participativo

    I want to pass numpy array to c++, but there is a deprecated numpy API and I don't know where to find the substitute. It shows me a warning message when I build my c++ code to make library.

    numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION

    Is there any problem to use deprecated API? If I use it, it runs only once and just quit my program without any further error/warning message(this cfunc should run many times in a loop in my python code that imports c library.). Of course if I disabled deprecated API, it just tells me that it cannot find that API.

    Here is a part of my code to receive numpy array and convert it to double array to handle it in c++

    #include <Python.h>
    #include "numpy\ndarraytypes.h"
    #include "numpy\ndarrayobject.h"
    #include "numpy\arrayobject.h"

    static PyObject* cfunc(PyObject* self, PyObject* args)
    {
    PyArrayObject* numpyarray;
    double* carray;

    if (!PyArg_ParseTuple(args, "O", &numpyarray))
    {
    return NULL;
    }
    carray = (double*)numpyarray->data; // When I build this code, it says 'data' is not a member of 'tagPyArrayObject'


    Please let me know if you have any idea.

    Thank you so much!

    Best wishes, JESuh

    Continue reading...

Compartilhe esta Página