Author: mattip <[email protected]>
Branch: fix-result-types
Changeset: r77677:9a045f1592bf
Date: 2015-05-29 09:46 +0300
http://bitbucket.org/pypy/pypy/changeset/9a045f1592bf/

Log:    fix tests, error msg format for -A compatability

diff --git a/pypy/module/micronumpy/strides.py 
b/pypy/module/micronumpy/strides.py
--- a/pypy/module/micronumpy/strides.py
+++ b/pypy/module/micronumpy/strides.py
@@ -229,11 +229,15 @@
     shape2 = w_arr2.get_shape()
     ret = _shape_agreement(shape1, shape2)
     if len(ret) < max(len(shape1), len(shape2)):
+        def format_shape(shape):
+            if len(shape) > 1:
+                return ",".join([str(x) for x in shape])
+            else:
+                return '%d,' % shape[0]
         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]),
-            ))
+                format_shape(shape1), format_shape(shape2)),
+            )
         )
     if not broadcast_down and len([x for x in ret if x != 1]) > len([x for x 
in shape2 if x != 1]):
         raise OperationError(space.w_ValueError,
diff --git a/pypy/module/micronumpy/test/test_nditer.py 
b/pypy/module/micronumpy/test/test_nditer.py
--- a/pypy/module/micronumpy/test/test_nditer.py
+++ b/pypy/module/micronumpy/test/test_nditer.py
@@ -113,12 +113,14 @@
             r.append((value, it.index))
         assert r == [(0, 0), (1, 2), (2, 4), (3, 1), (4, 3), (5, 5)]
 
-    @py.test.mark.xfail(reason="Fortran order not implemented")
     def test_iters_with_different_order(self):
         from numpy import nditer, array
 
         a = array([[1, 2], [3, 4]], order="C")
-        b = array([[1, 2], [3, 4]], order="F")
+        try:
+            b = array([[1, 2], [3, 4]], order="F")
+        except (NotImplementedError, ValueError):
+            skip('Fortran order not implemented')
 
         it = nditer([a, b])
 
@@ -217,7 +219,7 @@
         assert r == [(0, 0), (1, 1), (2, 2), (0, 3), (1, 4), (2, 5)]
         a = arange(2)
         exc = raises(ValueError, nditer, [a, b])
-        assert str(exc.value).find('shapes (2) (2,3)') > 0
+        assert str(exc.value).find('shapes (2,) (2,3)') > 0
 
     def test_outarg(self):
         from numpy import nditer, zeros, arange
@@ -246,7 +248,7 @@
         assert (c == [1., 4., 9.]).all()
         assert (b == c).all()
         exc = raises(ValueError, square2, arange(6).reshape(2, 3), out=b)
-        assert str(exc.value).find('cannot be broadcasted') > 0
+        assert str(exc.value).find("doesn't match the broadcast shape") > 0
 
     def test_outer_product(self):
         from numpy import nditer, arange
@@ -332,25 +334,25 @@
         i = nditer([a, None], [], [['readonly'], ['writeonly','allocate']],
                             op_axes=[[0,1,None], None],
                             itershape=(-1,-1,4))
-        assert_equal(i.operands[1].shape, (2,3,4))
-        assert_equal(i.operands[1].strides, (24,8,2))
+        assert i.operands[1].shape == (2,3,4)
+        assert i.operands[1].strides, (24,8,2)
 
         i = nditer([a.T, None], [], [['readonly'], ['writeonly','allocate']],
                             op_axes=[[0,1,None], None],
                             itershape=(-1,-1,4))
-        assert_equal(i.operands[1].shape, (3,2,4))
-        assert_equal(i.operands[1].strides, (8,24,2))
+        assert i.operands[1].shape, (3,2,4)
+        assert i.operands[1].strides, (8,24,2)
 
         i = nditer([a.T, None], [], [['readonly'], ['writeonly','allocate']],
                             order='F',
                             op_axes=[[0,1,None], None],
                             itershape=(-1,-1,4))
-        assert_equal(i.operands[1].shape, (3,2,4))
-        assert_equal(i.operands[1].strides, (2,6,12))
+        assert i.operands[1].shape, (3,2,4)
+        assert i.operands[1].strides, (2,6,12)
 
         # If we specify 1 in the itershape, it shouldn't allow broadcasting
         # of that dimension to a bigger value
-        assert_raises(ValueError, nditer, [a, None], [],
+        raises(ValueError, nditer, [a, None], [],
                             [['readonly'], ['writeonly','allocate']],
                             op_axes=[[0,1,None], None],
                             itershape=(-1,1,4))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to