[Numpy-svn] r3505 - trunk/numpy/core/tests

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Jan 8 22:57:53 CST 2007


Author: rkern
Date: 2007-01-08 22:57:50 -0600 (Mon, 08 Jan 2007)
New Revision: 3505

Modified:
   trunk/numpy/core/tests/test_regression.py
Log:
Add regression test for reduction with noncommutative ufuncs.

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2007-01-09 04:45:31 UTC (rev 3504)
+++ trunk/numpy/core/tests/test_regression.py	2007-01-09 04:57:50 UTC (rev 3505)
@@ -602,5 +602,16 @@
         ca = N.char.array(['Hi','There'])
         assert_equal(ca.startswith('H'),[True,False])
 
+    def check_noncommutative_reduce_accumulate(self, level=rlevel):
+        """Ticket #413"""
+        tosubtract = N.arange(5)
+        todivide = N.array([2.0, 0.5, 0.25])
+        assert_equal(N.subtract.reduce(tosubtract), -10)
+        assert_equal(N.divide.reduce(todivide), 16.0)
+        assert_array_equal(N.subtract.accumulate(tosubtract), 
+            N.array([0, -1, -3, -6, -10]))
+        assert_array_equal(N.divide.accumulate(todivide),
+            N.array([2., 4., 16.]))
+
 if __name__ == "__main__":
     NumpyTest().run()



More information about the Numpy-svn mailing list