[Cython] NumPy 1.7+ warnings

Frédéric Bastien nouiz at nouiz.org
Wed Jun 25 21:46:39 CEST 2014


Just to help people working on this, here is what I added in Theano:

        # numpy 1.7 deprecated the following macro but the new one didn't
        # existed in the past
        if bool(numpy_ver < [1, 7]):
            cxxflags.append("-D NPY_ARRAY_ENSUREARRAY=NPY_ENSUREARRAY")
            cxxflags.append("-D NPY_ARRAY_ENSURECOPY=NPY_ENSURECOPY")
            cxxflags.append("-D NPY_ARRAY_ALIGNED=NPY_ALIGNED")
            cxxflags.append("-D NPY_ARRAY_WRITEABLE=NPY_WRITEABLE")
            cxxflags.append("-D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL")
            cxxflags.append("-D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS")
            cxxflags.append("-D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS")


Some of the newer macro that are not deprecated, have been added only in
early version of NumPy. You could do an ifdef on the numpy bersion and add
those macro to be compatible with older numpy version when using the new
macro.

Fred


On Wed, Jun 25, 2014 at 3:16 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:

> Hi,
>
> recent NumPy versions are a bit unhappy about Cython code and generate
> deprecation warnings about it:
>
> .../numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning:
> #warning "Using deprecated NumPy API, disable it by " "#defining
> NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
>
> I don't know how much work it would be to port the C code properly, but it
> should be mostly about updating the implementation in Cython's
> "numpy/__init__.pxd", which is dated anyway.
>
> Given that NumPy 1.7 appeared not much more than a year ago, dropping
> support for older versions sounds a bit aggressive, but there should be a
> way to keep supporting them by defining some macros, similar to what we do
> for CPython in ModuleSetupCode.c. Any volunteers?
>
> The relevant bits of NumPy's C-API are described here:
>
> http://docs.scipy.org/doc/numpy-dev/reference/c-api.array.html
>
> My guess is that most of the work should be replacing direct access to
> ndarray struct fields with C macro calls. That won't easily fix user code,
> but it's the first major step on the way.
>
> Stefan
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> https://mail.python.org/mailman/listinfo/cython-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20140625/1c831651/attachment.html>


More information about the cython-devel mailing list