[Numpy-discussion] quick question about numpy deprecation warnings

Charles R Harris charlesr.harris@gmail....
Tue Jul 15 13:06:40 CDT 2008


On Tue, Jul 15, 2008 at 11:10 AM, Charles Doutriaux <doutriaux1@llnl.gov>
wrote:

> Hi I have a quick question and i hope somebody can answer me (I admit I
> should first really check the numpy doc)
>
> I have been porting old Numeric based C code to numpy/numpy.ma for the
> alst couple weeks.
>
> Just as I thought I was done, this morning I updatethe numpy trunk and I
> now get the following deprecation warnings
>
>  DeprecationWarning: PyArray_FromDims: use PyArray_SimpleNew.
> DeprecationWarning: PyArray_FromDimsAndDataAndDescr: use
> PyArray_NewFromDescr.
>
> My quick question is:
> can I simply replace the function names or is the arg list different?
>

Not quite. They are actually macros.

ndarrayobject.h:#define PyArray_SimpleNew(nd, dims,
typenum)                                  \
ndarrayobject.h-        PyArray_New(&PyArray_Type, nd, dims, typenum, NULL,
NULL, 0, 0, NULL)
ndarrayobject.h-
ndarrayobject.h:#define PyArray_SimpleNewFromData(nd, dims, typenum,
data)                    \
ndarrayobject.h-        PyArray_New(&PyArray_Type, nd, dims, typenum,
NULL,                   \
ndarrayobject.h-                    data, 0, NPY_CARRAY, NULL)
ndarrayobject.h-
ndarrayobject.h:#define PyArray_SimpleNewFromDescr(nd, dims,
descr)                           \
ndarrayobject.h-        PyArray_NewFromDescr(&PyArray_Type, descr, nd,
dims,                  \
ndarrayobject.h-                             NULL, NULL, 0, NULL)

The main change is that dims needs to point to npy_intp instead of int so
that 64 bit architectures can use large arrays. I'm not sure the recommended
replacements are the best, I just copied them from comments in the source
code. Travis could perhaps clarify things a bit for us.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080715/0a99d555/attachment.html 


More information about the Numpy-discussion mailing list