示例#1
0
 def test_testAddSumProd(self):
     # Test add, sum, product.
     (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
     assert_(eq(np.add.reduce(x), add.reduce(x)))
     assert_(eq(np.add.accumulate(x), add.accumulate(x)))
     assert_(eq(4, sum(array(4), axis=0)))
     assert_(eq(4, sum(array(4), axis=0)))
     assert_(eq(np.sum(x, axis=0), sum(x, axis=0)))
     assert_(eq(np.sum(filled(xm, 0), axis=0), sum(xm, axis=0)))
     assert_(eq(np.sum(x, 0), sum(x, 0)))
     assert_(eq(np.product(x, axis=0), product(x, axis=0)))
     assert_(eq(np.product(x, 0), product(x, 0)))
     assert_(eq(np.product(filled(xm, 1), axis=0), product(xm, axis=0)))
     if len(s) > 1:
         assert_(eq(np.concatenate((x, y), 1), concatenate((xm, ym), 1)))
         assert_(eq(np.add.reduce(x, 1), add.reduce(x, 1)))
         assert_(eq(np.sum(x, 1), sum(x, 1)))
         assert_(eq(np.product(x, 1), product(x, 1)))
示例#2
0
 def test_testAddSumProd(self):
     # Test add, sum, product.
     (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
     self.assertTrue(eq(np.add.reduce(x), add.reduce(x)))
     self.assertTrue(eq(np.add.accumulate(x), add.accumulate(x)))
     self.assertTrue(eq(4, sum(array(4), axis=0)))
     self.assertTrue(eq(4, sum(array(4), axis=0)))
     self.assertTrue(eq(np.sum(x, axis=0), sum(x, axis=0)))
     self.assertTrue(eq(np.sum(filled(xm, 0), axis=0), sum(xm, axis=0)))
     self.assertTrue(eq(np.sum(x, 0), sum(x, 0)))
     self.assertTrue(eq(np.product(x, axis=0), product(x, axis=0)))
     self.assertTrue(eq(np.product(x, 0), product(x, 0)))
     self.assertTrue(eq(np.product(filled(xm, 1), axis=0), product(xm, axis=0)))
     if len(s) > 1:
         self.assertTrue(eq(np.concatenate((x, y), 1), concatenate((xm, ym), 1)))
         self.assertTrue(eq(np.add.reduce(x, 1), add.reduce(x, 1)))
         self.assertTrue(eq(np.sum(x, 1), sum(x, 1)))
         self.assertTrue(eq(np.product(x, 1), product(x, 1)))
示例#3
0
 def test_reduce(self):
     a = self.d[0]
     assert_(not alltrue(a, axis=0))
     assert_(sometrue(a, axis=0))
     assert_equal(sum(a[:3], axis=0), 0)
     assert_equal(product(a, axis=0), 0)
示例#4
0
 def test_reduce(self):
     a = self.d[0]
     assert_(not alltrue(a, axis=0))
     assert_(sometrue(a, axis=0))
     assert_equal(sum(a[:3], axis=0), 0)
     assert_equal(product(a, axis=0), 0)
示例#5
0
 def test_reduce(self):
     a = self.d[0]
     self.assertFalse(alltrue(a, axis=0))
     self.assertTrue(sometrue(a, axis=0))
     self.assertEqual(sum(a[:3], axis=0), 0)
     self.assertEqual(product(a, axis=0), 0)
示例#6
0
 def test_reduce(self):
     a = self.d[0]
     self.assertFalse(alltrue(a, axis=0))
     self.assertTrue(sometrue(a, axis=0))
     self.assertEqual(sum(a[:3], axis=0), 0)
     self.assertEqual(product(a, axis=0), 0)