[pypy-commit] pypy numpy-multidim: merge

fijal noreply at buildbot.pypy.org
Thu Nov 24 16:12:07 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-multidim
Changeset: r49736:005f65935f44
Date: 2011-11-24 17:11 +0200
http://bitbucket.org/pypy/pypy/changeset/005f65935f44/

Log:	merge

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
@@ -52,8 +52,12 @@
 def shape_agreement(space, shape1, shape2):
     ret = _shape_agreement(shape1, shape2)
     if len(ret) < max(len(shape1), len(shape2)):
-        raise OperationError(space.w_ValueError, space.wrap(
-            "shape mismatch: objects cannot be broadcast to a single shape"))
+        raise OperationError(space.w_ValueError,
+            space.wrap("operands could not be broadcast together with shapes (%s) (%s)" % (
+                ",".join([str(x) for x in shape1]),
+                ",".join([str(x) for x in shape2]),
+            ))
+        )
     return ret
 
 def _shape_agreement(shape1, shape2):
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -912,7 +912,8 @@
         from numpypy import zeros
         a = zeros((4, 3, 2))
         b = zeros((4, 2))
-        raises(ValueError, b.__add__, a)
+        exc = raises(ValueError, lambda: a + b)
+        assert str(exc.value) == "operands could not be broadcast together with shapes (4,3,2) (4,2)"
 
     def test_reduce(self):
         from numpypy import array
@@ -977,7 +978,7 @@
         a = array((range(5), range(5, 10)), dtype="int16")
         b = a[1, 2:]
         assert repr(b) == "array([7, 8, 9], dtype=int16)"
-        #This is the way cpython numpy does it - an empty slice prints its shape
+        # an empty slice prints its shape
         b = a[2:1, ]
         assert repr(b) == "array([], shape=(0, 5), dtype=int16)"
 


More information about the pypy-commit mailing list