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

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Oct 27 11:03:21 CDT 2006


Author: oliphant
Date: 2006-10-27 11:03:16 -0500 (Fri, 27 Oct 2006)
New Revision: 3404

Modified:
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/scalartypes.inc.src
Log:
Fix PyArray_Scalar to handle user-defined types.

Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2006-10-27 06:26:54 UTC (rev 3403)
+++ trunk/numpy/core/src/arrayobject.c	2006-10-27 16:03:16 UTC (rev 3404)
@@ -1550,7 +1550,7 @@
 /*
   returns typenum to associate with this type >=PyArray_USERDEF.
   needs the userdecrs table and PyArray_NUMUSER variables
-  defined in arratypes.inc
+  defined in arraytypes.inc
 */
 /*MULTIARRAY_API
  Register Data type

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2006-10-27 06:26:54 UTC (rev 3403)
+++ trunk/numpy/core/src/scalartypes.inc.src	2006-10-27 16:03:16 UTC (rev 3404)
@@ -189,6 +189,15 @@
                                  NULL, NULL, 0, NULL);
         if (r==NULL) {Py_XDECREF(outcode); return NULL;}
 
+        if (PyDataType_ISUSERDEF(typecode)) {
+                /* Use setitem to set array from scalar */
+                if (typecode->f->setitem(scalar, PyArray_DATA(r), r) < 0) {
+                        Py_XDECREF(outcode);
+                        Py_DECREF(r);
+                        return NULL;
+                }
+        }
+
         memptr = scalar_value(scalar, typecode);
 #ifndef Py_UNICODE_WIDE
         if (typecode->type_num == PyArray_UNICODE) {



More information about the Numpy-svn mailing list