Suppressing warnings

1,608 views
Skip to first unread message

Gökhan Sever

unread,
Sep 21, 2011, 4:27:40 PM9/21/11
to cython...@googlegroups.com
Hello,

I want to be able to suppress the warning shown below:

In file included from /usr/include/numpy/ndarraytypes.h:1965:0,
                 from /usr/include/numpy/ndarrayobject.h:17,
                 from /usr/include/numpy/arrayobject.h:14,
                 from parcel.c:237:
/usr/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API"

Where to define this NPY_NO_DEPRECATED_API? I started getting this after source compiling a couple days old NumPy.


parcel.c: In function ‘__pyx_pf_6parcel_17SimpleParcelModel___init__’:
parcel.c:2851:10: warning: ‘__pyx_v_cloud_base_s’ may be used uninitialized in this function
parcel.c:2853:10: warning: ‘__pyx_v_my_tk_init’ may be used uninitialized in this function
parcel.c:2856:10: warning: ‘__pyx_v_cpmix’ may be used uninitialized in this function
parcel.c:2873:10: warning: ‘__pyx_v_dtk’ may be used uninitialized in this function
parcel.c:2877:10: warning: ‘__pyx_v_da’ may be used uninitialized in this function

I am quite sure that I am handling these properly. They are initialized based on a few if-blocks. Is there a compiler directive to ignore these messages?

Using -- Python 2.7 and Cython 0.15

Thanks.

--
Gökhan

Robert Bradshaw

unread,
Nov 15, 2011, 6:07:00 AM11/15/11
to cython...@googlegroups.com
On Wed, Sep 21, 2011 at 1:27 PM, Gökhan Sever <gokha...@gmail.com> wrote:
> Hello,
> I want to be able to suppress the warning shown below:
> In file included from /usr/include/numpy/ndarraytypes.h:1965:0,
>                  from /usr/include/numpy/ndarrayobject.h:17,
>                  from /usr/include/numpy/arrayobject.h:14,
>                  from parcel.c:237:
> /usr/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using
> deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API"
> Where to define this NPY_NO_DEPRECATED_API? I started getting this after
> source compiling a couple days old NumPy.

You can define it in a header file you include or directly with
distutils Extension(..., define_macros=[("NPY_NO_DEPRECATED_API",
None)]) or when compiling (e.g. passing -D NPY_NO_DEPRECATED_API to
gcc).

> parcel.c: In function ‘__pyx_pf_6parcel_17SimpleParcelModel___init__’:
> parcel.c:2851:10: warning: ‘__pyx_v_cloud_base_s’ may be used uninitialized
> in this function
> parcel.c:2853:10: warning: ‘__pyx_v_my_tk_init’ may be used uninitialized in
> this function
> parcel.c:2856:10: warning: ‘__pyx_v_cpmix’ may be used uninitialized in this
> function
> parcel.c:2873:10: warning: ‘__pyx_v_dtk’ may be used uninitialized in this
> function
> parcel.c:2877:10: warning: ‘__pyx_v_da’ may be used uninitialized in this
> function
> I am quite sure that I am handling these properly. They are initialized
> based on a few if-blocks. Is there a compiler directive to ignore these
> messages?

No, there's not. Could you provide some example code?

- Robert

Gökhan Sever

unread,
Nov 16, 2011, 5:40:59 PM11/16/11
to cython...@googlegroups.com
Hi,

On Tue, Nov 15, 2011 at 4:07 AM, Robert Bradshaw <robe...@math.washington.edu> wrote:
On Wed, Sep 21, 2011 at 1:27 PM, Gökhan Sever <gokha...@gmail.com> wrote:
> Hello,
> I want to be able to suppress the warning shown below:
> In file included from /usr/include/numpy/ndarraytypes.h:1965:0,
>                  from /usr/include/numpy/ndarrayobject.h:17,
>                  from /usr/include/numpy/arrayobject.h:14,
>                  from parcel.c:237:
> /usr/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using
> deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API"
> Where to define this NPY_NO_DEPRECATED_API? I started getting this after
> source compiling a couple days old NumPy.

You can define it in a header file you include or directly with
distutils Extension(..., define_macros=[("NPY_NO_DEPRECATED_API",
None)]) or when compiling (e.g. passing -D NPY_NO_DEPRECATED_API to
gcc).

Having this in setup.py:

ext_modules=[Extension("parcel", ["parcel.pyx"], extra_compile_args=["-O3", "-march=native", "-ffast-math","-funroll-loops"],
            define_macros=[("NPY_NO_DEPRECATED_API", None)])]

Getting the following build error:

[gsever@ccn cython]$ python setup.py build_ext -i
running build_ext
skipping 'parcel.c' Cython extension (up-to-date)
building 'parcel' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DNPY_NO_DEPRECATED_API -I/usr/include/python2.7 -c parcel.c -o build/temp.linux-x86_64-2.7/parcel.o -O3 -march=native -ffast-math -funroll-loops
parcel.c: In function ‘__pyx_pf_5numpy_7ndarray___getbuffer__’:
parcel.c:5428:69: error: ‘NPY_C_CONTIGUOUS’ undeclared (first use in this function)
parcel.c:5428:69: note: each undeclared identifier is reported only once for each function it appears in
parcel.c:5468:69: error: ‘NPY_F_CONTIGUOUS’ undeclared (first use in this function)
parcel.c:5632:3: error: ‘PyArrayObject’ has no member named ‘descr’
parcel.c:5633:50: error: ‘PyArrayObject’ has no member named ‘descr’
parcel.c: In function ‘__pyx_f_5numpy_set_array_base’:
parcel.c:7160:3: error: ‘PyArrayObject’ has no member named ‘base’
parcel.c:7160:3: error: ‘PyArrayObject’ has no member named ‘base’
parcel.c:7160:3: error: ‘PyArrayObject’ has no member named ‘base’
parcel.c:7160:3: error: ‘PyArrayObject’ has no member named ‘base’
parcel.c:7169:14: error: ‘PyArrayObject’ has no member named ‘base’
parcel.c: In function ‘__pyx_f_5numpy_get_array_base’:
parcel.c:7195:27: error: ‘PyArrayObject’ has no member named ‘base’
parcel.c:7219:5: error: ‘PyArrayObject’ has no member named ‘base’
parcel.c:7220:39: error: ‘PyArrayObject’ has no member named ‘base’
error: command 'gcc' failed with exit status 1

Likewise this has the same effect

extra_compile_args=["-O3", "-march=native", "-ffast-math","-funroll-loops", "-D NPY_NO_DEPRECATED_API"]

These extra_compile_args list is an experimental test to see how various compiler directives effect my simulation speeds and results.



> parcel.c: In function ‘__pyx_pf_6parcel_17SimpleParcelModel___init__’:
> parcel.c:2851:10: warning: ‘__pyx_v_cloud_base_s’ may be used uninitialized
> in this function
> parcel.c:2853:10: warning: ‘__pyx_v_my_tk_init’ may be used uninitialized in
> this function
> parcel.c:2856:10: warning: ‘__pyx_v_cpmix’ may be used uninitialized in this
> function
> parcel.c:2873:10: warning: ‘__pyx_v_dtk’ may be used uninitialized in this
> function
> parcel.c:2877:10: warning: ‘__pyx_v_da’ may be used uninitialized in this
> function
> I am quite sure that I am handling these properly. They are initialized
> based on a few if-blocks. Is there a compiler directive to ignore these
> messages?

No, there's not. Could you provide some example code?

- Robert

My code is under http://atmos.uwyo.edu/~gsever/data/cython/

That setup.py compiles properly with Cython version 0.15.1. But like I mentioned earlier I get the same warnings:

[gsever@ccn cython]$ python setup.py build_ext -i
running build_ext
skipping 'parcel.c' Cython extension (up-to-date)
building 'parcel' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c parcel.c -o build/temp.linux-x86_64-2.7/parcel.o -O3 -march=native -ffast-math -funroll-loops
In file included from /usr/include/numpy/ndarraytypes.h:1965:0,
                 from /usr/include/numpy/ndarrayobject.h:17,
                 from /usr/include/numpy/arrayobject.h:14,
                 from parcel.c:237:
/usr/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API"
parcel.c: In function ‘__pyx_f_6parcel_secant.clone.1’:
parcel.c:2716:10: warning: ‘__pyx_v_p’ may be used uninitialized in this function
parcel.c: In function ‘__pyx_pf_6parcel_17SimpleParcelModel___init__’:
parcel.c:2933:10: warning: ‘__pyx_v_cloud_base_s’ may be used uninitialized in this function
parcel.c:2935:10: warning: ‘__pyx_v_my_tk_init’ may be used uninitialized in this function
parcel.c:2938:10: warning: ‘__pyx_v_cpmix’ may be used uninitialized in this function
parcel.c:2955:10: warning: ‘__pyx_v_dtk’ may be used uninitialized in this function
parcel.c:2960:10: warning: ‘__pyx_v_da’ may be used uninitialized in this function
gcc -pthread -shared build/temp.linux-x86_64-2.7/parcel.o -L/usr/lib64 -lpython2.7 -o /home/gsever/Desktop/cython/parcel.so


--
Gökhan

Robert Bradshaw

unread,
Dec 1, 2011, 2:15:59 AM12/1/11
to cython...@googlegroups.com
Looks like you need to fix Cython to not use the deprecated API or
wait for someone else to do it. Personally, I'm not sure how hard this
would be or how recently the API was deprecated (if it's fairly
recent, we don't want to emit code using the new API and break anyone
using an older NumPy).

Jasmine Sandhu

unread,
May 3, 2013, 2:05:59 PM5/3/13
to cython...@googlegroups.com
Hi,

I wanted to follow up on this as we were trying to get rid of the warnings as well.
Has anyone successfully gotten rid of the warning?
Is numpy.pxd maintained by Cython community and are their plans to update that
in the near future to support the new numpy API?

On Wednesday, November 30, 2011 11:15:59 PM UTC-8, Robert Bradshaw wrote:
Looks like you need to fix Cython to not use the deprecated API or
wait for someone else to do it. Personally, I'm not sure how hard this
would be or how recently the API was deprecated (if it's fairly
recent, we don't want to emit code using the new API and break anyone
using an older NumPy).


It appears numpy will support old macros/functions by adding the include file npy_deprecated_api.h until the next
major release (2.0):

The Cython/Includes/numpy.pxd uses the deprecated macros/functions so 
adding the following symbol gives compiler errors.
#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
So, these names have changed to NPY_ARRAY_C_CONTIGUOUS and NPY_ARRAY_F_CONTIGUOUS.
It was easy to look these up in npy_deprecated_api.h and correct the names in
Cython's numpy.pxd. But after doing that I get the following errors:

/usr/include/AvailabilityMacros.h:108:14: warning: #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid.
gnome/cy_gnome/cy_mover.cpp: In function ‘int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject*, Py_buffer*, int)’:
gnome/cy_gnome/cy_mover.cpp:2191: error: ‘struct tagPyArrayObject’ has no member named ‘descr’
gnome/cy_gnome/cy_mover.cpp: In function ‘void __pyx_f_5numpy_set_array_base(PyArrayObject*, PyObject*)’:
gnome/cy_gnome/cy_mover.cpp:3723: error: ‘struct tagPyArrayObject’ has no member named ‘base’
gnome/cy_gnome/cy_mover.cpp:3723: error: ‘struct tagPyArrayObject’ has no member named ‘base’
gnome/cy_gnome/cy_mover.cpp:3723: error: ‘struct tagPyArrayObject’ has no member named ‘base’
gnome/cy_gnome/cy_mover.cpp:3723: error: ‘struct tagPyArrayObject’ has no member named ‘base’
gnome/cy_gnome/cy_mover.cpp:3732: error: ‘struct tagPyArrayObject’ has no member named ‘base’
gnome/cy_gnome/cy_mover.cpp: In function ‘PyObject* __pyx_f_5numpy_get_array_base(PyArrayObject*)’:
gnome/cy_gnome/cy_mover.cpp:3758: error: ‘struct tagPyArrayObject’ has no member named ‘base’
gnome/cy_gnome/cy_mover.cpp:3782: error: ‘struct tagPyArrayObject’ has no member named ‘base’
gnome/cy_gnome/cy_mover.cpp:3783: error: ‘struct tagPyArrayObject’ has no member named ‘base’

I haven't delved into these yet and I'm not even sure where to start.

Anyone have any new thoughts on this topic?

Thanks,
Jasmine
Reply all
Reply to author
Forward
0 new messages