Пример #1
0
 def testSparseSum(self):
     s1 = SparseNDArray(self.s1)
     v1 = SparseNDArray(self.v1, shape=(3, ))
     self.assertEqual(s1.sum(), self.s1.sum())
     np.testing.assert_array_equal(
         s1.sum(axis=1),
         np.asarray(self.s1.sum(axis=1)).reshape(2))
     np.testing.assert_array_equal(
         s1.sum(axis=0),
         np.asarray(self.s1.sum(axis=0)).reshape(3))
     np.testing.assert_array_equal(v1.sum(), np.asarray(self.v1_data.sum()))
Пример #2
0
def test_sparse_sum():
    s1 = SparseNDArray(s1_data)
    v = SparseNDArray(v1, shape=(3, ))
    assert s1.sum() == s1.sum()
    np.testing.assert_array_equal(s1.sum(axis=1),
                                  np.asarray(s1.sum(axis=1)).reshape(2))
    np.testing.assert_array_equal(s1.sum(axis=0),
                                  np.asarray(s1.sum(axis=0)).reshape(3))
    np.testing.assert_array_equal(v.sum(), np.asarray(v1_data.sum()))
Пример #3
0
 def testSparseSum(self):
     s1 = SparseNDArray(self.s1)
     self.assertEqual(s1.sum(), self.s1.sum())
     np.testing.assert_array_equal(
         s1.sum(axis=1),
         np.asarray(self.s1.sum(axis=1)).reshape(2))