[Numpy-svn] r3299 - in trunk/numpy: core/src lib

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Oct 10 03:52:23 CDT 2006


Author: oliphant
Date: 2006-10-10 03:52:18 -0500 (Tue, 10 Oct 2006)
New Revision: 3299

Modified:
   trunk/numpy/core/src/scalartypes.inc.src
   trunk/numpy/lib/shape_base.py
Log:
Fix segfault in .imag for real array scalars.  Be specific about infix multiplication.

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2006-10-09 20:44:45 UTC (rev 3298)
+++ trunk/numpy/core/src/scalartypes.inc.src	2006-10-10 08:52:18 UTC (rev 3299)
@@ -834,9 +834,9 @@
         PyObject *ret;
         int typenum;
 
-        typecode = _realdescr_fromcomplexscalar(self, &typenum);
         if (PyArray_IsScalar(self, ComplexFloating)) {
-            ret = PyArray_Scalar((char *)scalar_value(self, NULL)
+                typecode = _realdescr_fromcomplexscalar(self, &typenum);
+                ret = PyArray_Scalar((char *)scalar_value(self, NULL)
                                  + typecode->elsize, typecode, NULL);
         }
         else if (PyArray_IsScalar(self, Object)) {
@@ -854,6 +854,7 @@
         }
         else {
                 char *temp;
+                typecode = PyArray_DescrFromScalar(self);
                 temp = PyDataMem_NEW(typecode->elsize);
                 memset(temp, '\0', typecode->elsize);
                 ret = PyArray_Scalar(temp, typecode, NULL);

Modified: trunk/numpy/lib/shape_base.py
===================================================================
--- trunk/numpy/lib/shape_base.py	2006-10-09 20:44:45 UTC (rev 3298)
+++ trunk/numpy/lib/shape_base.py	2006-10-10 08:52:18 UTC (rev 3299)
@@ -552,7 +552,7 @@
     a = array(a,copy=False,subok=True,ndmin=b.ndim)
     ndb, nda = b.ndim, a.ndim
     if (nda == 0 or ndb == 0):
-        return a * b
+        return _nx.multiply(a,b)
     as = a.shape
     bs = b.shape
     if not a.flags.contiguous:



More information about the Numpy-svn mailing list