Author: mattip
Branch: numpypy-out
Changeset: r52624:9c8325480862
Date: 2012-02-18 21:50 +0200
http://bitbucket.org/pypy/pypy/changeset/9c8325480862/

Log:    shape_agreement needs a bit of help

diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -261,11 +261,12 @@
             return space.wrap(out)
         if out:
             #Test shape compatability
-            if not shape_agreement(space, w_obj.shape, out.shape):
+            broadcast_shape =  shape_agreement(space, w_obj.shape, out.shape)
+            if not broadcast_shape or broadcast_shape != out.shape:
                 raise operationerrfmt(space.w_ValueError,
-                    'output parameter shape mismatch, expecting [%s]' +
-                    ' , got [%s]', 
-                    ",".join([str(x) for x in shape]),
+                    'output parameter shape mismatch, could not broadcast 
[%s]' +
+                    ' , to [%s]', 
+                    ",".join([str(x) for x in w_obj.shape]),
                     ",".join([str(x) for x in out.shape]),
                     )
             w_res = Call1(self.func, self.name, out.shape, calc_dtype,
diff --git a/pypy/module/micronumpy/test/test_outarg.py 
b/pypy/module/micronumpy/test/test_outarg.py
--- a/pypy/module/micronumpy/test/test_outarg.py
+++ b/pypy/module/micronumpy/test/test_outarg.py
@@ -54,8 +54,10 @@
         assert (c == b).all()
 
         #Test shape agreement
-        a=zeros((3,4))
-        b=zeros((3,5))
+        a = zeros((3,4))
+        b = zeros((3,5))
+        raises(ValueError, 'negative(a, out=b)')
+        b = zeros((1,4))
         raises(ValueError, 'negative(a, out=b)')
 
     def test_ufunc_cast(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to