[Numpy-svn] r5407 - in trunk/numpy: core/include/numpy core/src fft

numpy-svn at scipy.org numpy-svn at scipy.org
Sun Jul 13 19:56:59 EDT 2008


Author: charris
Date: 2008-07-13 18:56:51 -0500 (Sun, 13 Jul 2008)
New Revision: 5407

Modified:
   trunk/numpy/core/include/numpy/ndarrayobject.h
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/multiarraymodule.c
   trunk/numpy/fft/fftpack_litemodule.c
Log:
Move DEPRECATE macro to ndarrayobject.h.
Deprecate PyArray_As1D.
Remove deprecated functions from fftpack_listmodule.c.
There may need to be further fixes on 64 bit platforms, we will see.


Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2008-07-13 22:15:13 UTC (rev 5406)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2008-07-13 23:56:51 UTC (rev 5407)
@@ -1,4 +1,5 @@
-/* DON'T INCLUDE THIS DIRECTLY.
+/*
+ * DON'T INCLUDE THIS DIRECTLY.
  */
 
 #ifndef NPY_NDARRAYOBJECT_H
@@ -2007,4 +2008,12 @@
 }
 #endif
 
+/* Define python version independent deprecation macro */
+
+#if PY_VERSION_HEX >= 0x02050000
+#define DEPRECATE(msg) PyErr_WarnEx(PyExc_DeprecationWarning,msg,1)
+#else
+#define DEPRECATE(msg) PyErr_Warn(PyExc_DeprecationWarning,msg)
+#endif
+
 #endif /* NPY_NDARRAYOBJECT_H */

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2008-07-13 22:15:13 UTC (rev 5406)
+++ trunk/numpy/core/src/arrayobject.c	2008-07-13 23:56:51 UTC (rev 5407)
@@ -22,12 +22,6 @@
 */
 /*#include <stdio.h>*/
 
-#if PY_VERSION_HEX >= 0x02050000
-#define DEPRECATE(msg) PyErr_WarnEx(PyExc_DeprecationWarning,msg,1)
-#else
-#define DEPRECATE(msg) PyErr_Warn(PyExc_DeprecationWarning,msg)
-#endif
-
 /*NUMPY_API
  * Get Priority from object
  */

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2008-07-13 22:15:13 UTC (rev 5406)
+++ trunk/numpy/core/src/multiarraymodule.c	2008-07-13 23:56:51 UTC (rev 5407)
@@ -1665,7 +1665,13 @@
 {
     intp newd1;
     PyArray_Descr *descr;
+    int err;
+    char msg[] = "PyArray_As1D: use PyArray_AsCArray instead.";
 
+    err = DEPRECATE(msg);
+    if (err < 0) {
+        return -1;
+    }
     descr = PyArray_DescrFromType(typecode);
     if (PyArray_AsCArray(op, (void *)ptr, &newd1, 1, descr) == -1)
         return -1;

Modified: trunk/numpy/fft/fftpack_litemodule.c
===================================================================
--- trunk/numpy/fft/fftpack_litemodule.c	2008-07-13 22:15:13 UTC (rev 5406)
+++ trunk/numpy/fft/fftpack_litemodule.c	2008-07-13 23:56:51 UTC (rev 5407)
@@ -13,8 +13,10 @@
 {
     PyObject *op1, *op2;
     PyArrayObject *data;
+    PyArray_Descr *descr;
     double *wsave, *dptr;
-    int npts, nsave, nrepeats, i;
+    npy_intp nsave;
+    int npts, nrepeats, i;
 
     if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) {
         return NULL;
@@ -24,7 +26,8 @@
     if (data == NULL) {
         return NULL;
     }
-    if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) {
+    descr = PyArray_DescrFromType(PyArray_DOUBLE);
+    if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) {
         goto fail;
     }
     if (data == NULL) {
@@ -61,8 +64,10 @@
 {
     PyObject *op1, *op2;
     PyArrayObject *data;
+    PyArray_Descr *descr;
     double *wsave, *dptr;
-    int npts, nsave, nrepeats, i;
+    npy_intp nsave;
+    int npts, nrepeats, i;
 
     if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) {
         return NULL;
@@ -72,7 +77,8 @@
     if (data == NULL) {
         return NULL;
     }
-    if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) {
+    descr = PyArray_DescrFromType(PyArray_DOUBLE);
+    if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) {
         goto fail;
     }
     if (data == NULL) {
@@ -108,15 +114,16 @@
 fftpack_cffti(PyObject *self, PyObject *args)
 {
     PyArrayObject *op;
-    int dim, n;
+    npy_intp dim;
+    long n;
 
-    if (!PyArg_ParseTuple(args, "i", &n)) {
+    if (!PyArg_ParseTuple(args, "l", &n)) {
         return NULL;
     }
     /*Magic size needed by cffti*/
     dim = 4*n + 15;
     /*Create a 1 dimensional array of dimensions of type double*/
-    op = (PyArrayObject *)PyArray_FromDims(1, &dim, PyArray_DOUBLE);
+    op = (PyArrayObject *)PyArray_SimpleNew(1, &dim, PyArray_DOUBLE);
     if (op == NULL) {
         return NULL;
     }
@@ -135,8 +142,10 @@
 {
     PyObject *op1, *op2;
     PyArrayObject *data, *ret;
+    PyArray_Descr *descr;
     double *wsave, *dptr, *rptr;
-    int npts, nsave, nrepeats, i, rstep;
+    npy_intp nsave;
+    int npts, nrepeats, i, rstep;
 
     if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) {
         return NULL;
@@ -153,7 +162,8 @@
     data->dimensions[data->nd - 1] = npts;
     rstep = (ret->dimensions[ret->nd - 1])*2;
 
-    if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) {
+    descr = PyArray_DescrFromType(PyArray_DOUBLE);
+    if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) {
         goto fail;
     }
     if (data == NULL || ret == NULL) {
@@ -198,8 +208,10 @@
 {
     PyObject *op1, *op2;
     PyArrayObject *data, *ret;
+    PyArray_Descr *descr;
     double *wsave, *dptr, *rptr;
-    int npts, nsave, nrepeats, i;
+    npy_intp nsave;
+    int npts, nrepeats, i;
 
     if(!PyArg_ParseTuple(args, "OO", &op1, &op2)) {
         return NULL;
@@ -213,7 +225,8 @@
     ret = (PyArrayObject *)PyArray_Zeros(data->nd, data->dimensions,
             PyArray_DescrFromType(PyArray_DOUBLE), 0);
 
-    if (PyArray_As1D(&op2, (char **)&wsave, &nsave, PyArray_DOUBLE) == -1) {
+    descr = PyArray_DescrFromType(PyArray_DOUBLE);
+    if (PyArray_AsCArray(&op2, (void *)&wsave, &nsave, 1, descr) == -1) {
         goto fail;
     }
     if (data == NULL || ret == NULL) {
@@ -229,8 +242,8 @@
     dptr = (double *)data->data;
 
     NPY_SIGINT_ON;
-    for (i=0; i<nrepeats; i++) {
-        memcpy((char *)(rptr+1), (dptr+2), (npts-1)*sizeof(double));
+    for (i = 0; i < nrepeats; i++) {
+        memcpy((char *)(rptr + 1), (dptr + 2), (npts - 1)*sizeof(double));
         rptr[0] = dptr[0];
         rfftb(npts, rptr, wsave);
         rptr += npts;
@@ -255,15 +268,16 @@
 fftpack_rffti(PyObject *self, PyObject *args)
 {
   PyArrayObject *op;
-  int dim, n;
+  npy_intp dim;
+  long n;
 
-  if (!PyArg_ParseTuple(args, "i", &n)) {
+  if (!PyArg_ParseTuple(args, "l", &n)) {
       return NULL;
   }
   /*Magic size needed by rffti*/
   dim = 2*n + 15;
   /*Create a 1 dimensional array of dimensions of type double*/
-  op = (PyArrayObject *)PyArray_FromDims(1, &dim, PyArray_DOUBLE);
+  op = (PyArrayObject *)PyArray_SimpleNew(1, &dim, PyArray_DOUBLE);
   if (op == NULL) {
       return NULL;
   }




More information about the Numpy-svn mailing list