Example #1
0
 def test_sum_axis_zeroth(self):
     x = np.random.randn(100, 100)
     expected = x.sum(axis=0)
     actual = kahan_sum(x, axis=0)
     self.assertTrue(np.allclose(expected, actual))
Example #2
0
 def test_sum_axis_first_keepdims(self):
     x = np.random.randn(100, 100)
     expected = x.sum(axis=1, keepdims=True)
     actual = kahan_sum(x, axis=1, keepdims=True)
     self.assertTrue(np.allclose(expected, actual))
Example #3
0
 def test_sum(self):
     x = np.random.randn(int(1e5))
     expected = x.sum()
     actual = kahan_sum(x)
     self.assertTrue(np.allclose(expected, actual))