[Numpy-svn] r5400 - trunk/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sun Jul 13 13:19:21 CDT 2008


Author: charris
Date: 2008-07-13 13:19:16 -0500 (Sun, 13 Jul 2008)
New Revision: 5400

Modified:
   trunk/numpy/core/src/arrayobject.c
Log:
Deprecate PyArray_FromDims and PyArray_FromDimsAndDataAndDescr.
There will be warnings issued in np.test() until fftpack is fixed.


Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2008-07-12 23:49:10 UTC (rev 5399)
+++ trunk/numpy/core/src/arrayobject.c	2008-07-13 18:19:16 UTC (rev 5400)
@@ -1311,26 +1311,24 @@
                                 char *data)
 {
     PyObject *ret;
-#if SIZEOF_INTP != SIZEOF_INT
     int i;
     intp newd[MAX_DIMS];
-#endif
+    char msg[] = "PyArray_FromDimsAndDataAndDescr";
+    int err;
 
+    err = PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1);
+    if (err < 0) {
+        return NULL;
+    }
     if (!PyArray_ISNBO(descr->byteorder))
         descr->byteorder = '=';
-
-#if SIZEOF_INTP != SIZEOF_INT
-    for(i=0; i<nd; i++) newd[i] = (intp) d[i];
+    for(i = 0; i < nd; i++) {
+        newd[i] = (intp) d[i];
+    }
     ret = PyArray_NewFromDescr(&PyArray_Type, descr,
                                nd, newd,
                                NULL, data,
                                (data ? CARRAY : 0), NULL);
-#else
-    ret = PyArray_NewFromDescr(&PyArray_Type, descr,
-                               nd, (intp *)d,
-                               NULL, data,
-                               (data ? CARRAY : 0), NULL);
-#endif
     return ret;
 }
 
@@ -1341,13 +1339,21 @@
 PyArray_FromDims(int nd, int *d, int type)
 {
     PyObject *ret;
+    char msg[] = "PyArray_FromDims";
+    int err;
+
+    err = PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1);
+    if (err < 0) {
+        return NULL;
+    }
     ret = PyArray_FromDimsAndDataAndDescr(nd, d,
                                           PyArray_DescrFromType(type),
                                           NULL);
-    /* Old FromDims set memory to zero --- some algorithms
-       relied on that.  Better keep it the same. If
-       Object type, then it's already been set to zero, though.
-    */
+    /*
+     * Old FromDims set memory to zero --- some algorithms
+     * relied on that.  Better keep it the same. If
+     * Object type, then it's already been set to zero, though.
+     */
     if (ret && (PyArray_DESCR(ret)->type_num != PyArray_OBJECT)) {
         memset(PyArray_DATA(ret), 0, PyArray_NBYTES(ret));
     }



More information about the Numpy-svn mailing list