예제 #1
0
 def test_abs_frecuenty(self):
     M = SparseMatrix(shape=(10, 10, 10))
     M[1, 2, 3] = 2
     M[3, 2, 1] = 2
     M[2, 2, 2] = 2
     R = M.abs_frecuency()
     assert (R[0, 1] == 997) and (R[1, 1] == 3), 'Error en la frecuencia'
예제 #2
0
 def test_randint(self):
     M = SparseMatrix.randint(self.low, self.high, self.sparsity,
                              self.shape, self.fill_value)
     self.assertGreaterEqual(M.min(), self.low)
     self.assertLess(M.max(), self.high)
     n = float(np.array(self.shape).prod())
     self.assertEqual(M.T.shape[0] / n, self.sparsity)
예제 #3
0
 def test_max_axis(self):
     M = SparseMatrix.from_numpy(self.A)
     print(M.max(axis=1).shape)
예제 #4
0
 def test_add_int(self):
     M = SparseMatrix.from_numpy(self.A)
     assert np.all((M + 10).to_numpy() == (self.A +
                                           10)), 'Error suma entero'
예제 #5
0
 def test_setitem_all_one(self):
     M = SparseMatrix.from_numpy(self.A)
     M[:, :, :] = -1000
     assert M.mean() == -1000, ''
예제 #6
0
 def test_setitem_one_vs_one(self):
     M = SparseMatrix.from_numpy(self.A)
     for i in range(100):
         self.A[i, i, i] = -1000
         M[i, i, i] = -1000
         self.assertEqual(self.A[i, i, i], M[i, i, i])
예제 #7
0
 def test_var(self):
     M = SparseMatrix.from_numpy(self.A)
     self.assertEqual(round(M.var(), 5), round(self.A.var(), 5))
예제 #8
0
 def test_mean(self):
     M = SparseMatrix.from_numpy(self.A)
     self.assertEqual(round(M.mean(), 5), round(self.A.mean(), 5))
예제 #9
0
 def test_max(self):
     M = SparseMatrix.from_numpy(self.A)
     self.assertEqual(M.max(), self.A.max())
예제 #10
0
 def test_sum(self):
     M = SparseMatrix.from_numpy(self.A)
     self.assertEqual(M.sum(), self.A.sum())
예제 #11
0
 def test_to_numpy(self):
     M = SparseMatrix.from_numpy(self.A)
     M = M.to_numpy()
     assert np.all(M == self.A), 'No cumple el máximo'
예제 #12
0
 def test_from_numpy(self):
     M = SparseMatrix.from_numpy(self.A)
     self.assertEqual(M.shape.prod(), np.array(self.shape).prod())
     self.assertEqual(M.sum(), self.A.sum())
     self.assertGreaterEqual(M.min(), self.low)
     self.assertLess(M.max(), self.high)