[pypy-commit] pypy numpypy-axisops: add tests

mattip noreply at buildbot.pypy.org
Thu Jan 12 23:05:44 CET 2012


Author: mattip
Branch: numpypy-axisops
Changeset: r51294:5c5db1df52eb
Date: 2012-01-13 00:05 +0200
http://bitbucket.org/pypy/pypy/changeset/5c5db1df52eb/

Log:	add tests

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
@@ -748,14 +748,26 @@
 
     def test_reduce_nd(self):
         skip("xxx")
-        from numpypy import arange
+        from numpypy import arange, array
         a = arange(15).reshape(5, 3)
         assert a.sum() == 105
         assert a.max() == 14
+        assert array([]).sum() = 0.0
+        raises(ValueError,'array([]).sum()')
         assert (a.sum(0) == [30, 35, 40]).all()
         assert (a.sum(1) == [3, 12, 21, 30, 39]).all()
         assert (a.max(0) == [12, 13, 14]).all()
         assert (a.max(1) == [2, 5, 8, 11, 14]).all()
+        assert ((a + a).max() == 28)
+        assert ((a + a).max(0) == [24, 26. 28]).all()
+        assert ((a + a).sum(1) == [6, 24, 42, 60, 78]).all()
+        a = array(range(105)).reshape(3, 5, 7)
+        assert (a[:, 1, :].sum(0) == [126, 129, 132, 135, 138, 141, 144]).all()
+        assert (a[:, 1, :].sum(1) == [70, 315, 560]).all()
+        raises (ValueError, 'a[:, 1, :].sum(2)')
+        assert ((a + a).T.sum(2).T == (a + a).sum(0)).all()
+        assert (a.reshape(1,-1).sum(0) == range(105)).all()
+        assert (a.reshape(1,-1).sum(1) == 5460)
 
     def test_identity(self):
         from numpypy import identity, array


More information about the pypy-commit mailing list