[pypy-commit] pypy numpy-multidim: match the percise error message of numpy
alex_gaynor
noreply at buildbot.pypy.org
Thu Nov 24 16:08:09 CET 2011
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: numpy-multidim
Changeset: r49733:61e9f8ceeb23
Date: 2011-11-24 09:07 -0600
http://bitbucket.org/pypy/pypy/changeset/61e9f8ceeb23/
Log: match the percise error message of numpy
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
More information about the pypy-commit
mailing list