[pypy-commit] pypy default: Fix for flatten() with certain types of arrays.

alex_gaynor noreply at buildbot.pypy.org
Sat Jan 21 18:33:33 CET 2012


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r51595:fe8a844cd0d0
Date: 2012-01-21 11:30 -0600
http://bitbucket.org/pypy/pypy/changeset/fe8a844cd0d0/

Log:	Fix for flatten() with certain types of arrays.

diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -925,14 +925,15 @@
                                self.left.create_sig(), self.right.create_sig())
 
 class SliceArray(Call2):
-    def __init__(self, shape, dtype, left, right):
+    def __init__(self, shape, dtype, left, right, no_broadcast=False):
+        self.no_broadcast = no_broadcast
         Call2.__init__(self, None, 'sliceloop', shape, dtype, dtype, left,
                        right)
 
     def create_sig(self):
         lsig = self.left.create_sig()
         rsig = self.right.create_sig()
-        if self.shape != self.right.shape:
+        if not self.no_broadcast and self.shape != self.right.shape:
             return signature.SliceloopBroadcastSignature(self.ufunc,
                                                          self.name,
                                                          self.calc_dtype,
@@ -1166,7 +1167,7 @@
         if self.supports_fast_slicing():
             array._fast_setslice(space, self)
         else:
-            arr = SliceArray(array.shape, array.dtype, array, self)
+            arr = SliceArray(array.shape, array.dtype, array, self, no_broadcast=True)
             array._sliceloop(arr)
         return array
 


More information about the pypy-commit mailing list