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

numpy-svn at scipy.org numpy-svn at scipy.org
Wed Aug 6 13:34:57 EDT 2008


Author: oliphant
Date: 2008-08-06 12:34:56 -0500 (Wed, 06 Aug 2008)
New Revision: 5616

Modified:
   trunk/numpy/core/include/numpy/ndarrayobject.h
   trunk/numpy/core/src/arraymethods.c
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/arraytypes.inc.src
Log:
Fix ticket #877 along with other bugs not yet reported for data-types with titles.

Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2008-08-06 00:12:01 UTC (rev 5615)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2008-08-06 17:34:56 UTC (rev 5616)
@@ -2014,10 +2014,16 @@
 
 #include "old_defines.h"
 
-#ifdef __cplusplus
-}
-#endif
+/* 
+   Check to see if this key in the dictionary is the "title" 
+   entry of the tuple (i.e. a duplicate dictionary entry in the fields
+   dict. 
+*/
 
+#define NPY_TITLE_KEY(key, value) ((PyTuple_GET_SIZE((value))==3) && \
+				   (PyTuple_GET_ITEM((value), 2) == (key)))
+
+
 /* Define python version independent deprecation macro */
 
 #if PY_VERSION_HEX >= 0x02050000
@@ -2026,4 +2032,10 @@
 #define DEPRECATE(msg) PyErr_Warn(PyExc_DeprecationWarning,msg)
 #endif
 
+
+#ifdef __cplusplus
+}
+#endif
+
+
 #endif /* NPY_NDARRAYOBJECT_H */

Modified: trunk/numpy/core/src/arraymethods.c
===================================================================
--- trunk/numpy/core/src/arraymethods.c	2008-08-06 00:12:01 UTC (rev 5615)
+++ trunk/numpy/core/src/arraymethods.c	2008-08-06 17:34:56 UTC (rev 5616)
@@ -1006,6 +1006,7 @@
         int offset;
         Py_ssize_t pos=0;
         while (PyDict_Next(dtype->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                   &title)) return;
             _deepcopy_call(iptr + offset, optr + offset, new,

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2008-08-06 00:12:01 UTC (rev 5615)
+++ trunk/numpy/core/src/arrayobject.c	2008-08-06 17:34:56 UTC (rev 5616)
@@ -13,7 +13,7 @@
   Travis Oliphant,  oliphant at ee.byu.edu
   Brigham Young Univeristy
 
-:8613
+
 maintainer email:  oliphant.travis at ieee.org
 
   Numarray design (which provided guidance) by
@@ -171,6 +171,7 @@
         Py_ssize_t pos=0;
 
         while (PyDict_Next(descr->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                   &title)) {
                 return;
@@ -202,8 +203,10 @@
             PyArray_Descr *new;
             int offset;
             Py_ssize_t pos=0;
+
             while (PyDict_Next(descr->fields, &pos, &key, &value)) {
-                if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
+		if NPY_TITLE_KEY(key, value) continue;
+		if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                       &title)) {
                     return;
                 }
@@ -4814,6 +4817,7 @@
 
         op = (cmp_op == Py_EQ ? n_ops.logical_and : n_ops.logical_or);
         while (PyDict_Next(self->descr->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             a = PyArray_EnsureAnyArray(array_subscript(self, key));
             if (a==NULL) {
                 Py_XDECREF(res);
@@ -5706,6 +5710,7 @@
         int offset;
         Py_ssize_t pos=0;
         while (PyDict_Next(dtype->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                   &title)) return;
             _putzero(optr + offset, zero, new);
@@ -5876,6 +5881,7 @@
         int offset;
         Py_ssize_t pos=0;
         while (PyDict_Next(dtype->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                   &title)) return;
             _fillobject(optr + offset, obj, new);
@@ -11296,6 +11302,7 @@
         int offset;
         Py_ssize_t pos=0;
         while(PyDict_Next(self->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                   &title)) return -1;
             if (!_arraydescr_isnative(new)) return 0;
@@ -11567,6 +11574,7 @@
         int offset;
         Py_ssize_t pos=0;
         while (PyDict_Next(self->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                                   &title)) {
                 PyErr_Clear();
@@ -11760,6 +11768,7 @@
         /* make new dictionary with replaced */
         /* PyArray_Descr Objects */
         while(PyDict_Next(self->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyString_Check(key) ||          \
                 !PyTuple_Check(value) ||                    \
                 ((len=PyTuple_GET_SIZE(value)) < 2))

Modified: trunk/numpy/core/src/arraytypes.inc.src
===================================================================
--- trunk/numpy/core/src/arraytypes.inc.src	2008-08-06 00:12:01 UTC (rev 5615)
+++ trunk/numpy/core/src/arraytypes.inc.src	2008-08-06 17:34:56 UTC (rev 5616)
@@ -1306,6 +1306,7 @@
         Py_ssize_t pos=0;
         descr = arr->descr;
         while (PyDict_Next(descr->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                         &title)) {
                 arr->descr=descr;return;
@@ -1357,6 +1358,7 @@
         Py_ssize_t pos=0;
         descr = arr->descr;  /* Save it */
         while (PyDict_Next(descr->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                         &title)) {
                 arr->descr=descr;return;
@@ -1596,6 +1598,7 @@
         descr = ap->descr;
         savedflags = ap->flags;
         while (PyDict_Next(descr->fields, &pos, &key, &value)) {
+	    if NPY_TITLE_KEY(key, value) continue;
             if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
                         &title)) {PyErr_Clear(); continue;}
             ap->descr = new;




More information about the Numpy-svn mailing list