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

numpy-svn at scipy.org numpy-svn at scipy.org
Sat Oct 28 04:26:40 CDT 2006


Author: oliphant
Date: 2006-10-28 04:26:36 -0500 (Sat, 28 Oct 2006)
New Revision: 3412

Modified:
   trunk/numpy/core/include/numpy/ndarrayobject.h
   trunk/numpy/core/src/scalartypes.inc.src
Log:
One more fix for allowing use of setitem in PyArray_FromScalar instead of memcpy

Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2006-10-28 09:18:00 UTC (rev 3411)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2006-10-28 09:26:36 UTC (rev 3412)
@@ -1126,6 +1126,9 @@
 #define NPY_USE_GETITEM     0x20  /* Use f.getitem when extracting elements 
                                      of this data-type */
 
+#define NPY_USE_SETITEM     0x40  /* Use f.setitem when setting creating
+                                     0-d array from this data-type.
+                                  */
 
 /* These are inherited for global data-type if any data-types in the field 
    have them */

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2006-10-28 09:18:00 UTC (rev 3411)
+++ trunk/numpy/core/src/scalartypes.inc.src	2006-10-28 09:26:36 UTC (rev 3412)
@@ -250,7 +250,14 @@
                                  NULL, NULL, 0, NULL);
         if (r==NULL) {Py_XDECREF(outcode); return NULL;}
 
-
+        if (PyDataType_FLAGCHK(typecode, NPY_USE_SETITEM)) {
+                if (typecode->f->setitem(scalar, PyArray_DATA(r), r) < 0) {
+                        Py_XDECREF(outcode); Py_DECREF(r);
+                        return NULL;
+                }
+                goto finish;
+        }
+        
         memptr = scalar_value(scalar, typecode);
         
 #ifndef Py_UNICODE_WIDE
@@ -268,6 +275,7 @@
                 }
         }
 
+ finish:
         if (outcode == NULL) return r;
 
         if (outcode->type_num == typecode->type_num) {



More information about the Numpy-svn mailing list