Esempio n. 1
0
 def test_rand_min_max(self):
     m = (rand(self.sds,
               rows=shape[0],
               cols=shape[1],
               min=min_max[0],
               max=min_max[1]).compute())
     self.assertTrue((m.min() >= min_max[0]) and (m.max() <= min_max[1]))
Esempio n. 2
0
    def test_rand_sparsity(self):
        m = rand(self.sds,
                 rows=shape[0],
                 cols=shape[1],
                 sparsity=sparsity,
                 seed=0).compute()
        non_zero_value_percent = np.count_nonzero(m) * 100 / np.prod(m.shape)

        self.assertTrue(
            math.isclose(non_zero_value_percent, sparsity * 100, rel_tol=5))
Esempio n. 3
0
    def test_rand_normal_distribution(self):
        m = (rand(self.sds,
                  rows=dist_shape[0],
                  cols=dist_shape[1],
                  pdf="normal",
                  min=min_max[0],
                  max=min_max[1],
                  seed=0).compute())

        dist = find_best_fit_distribution(m.flatten("F"), distributions)
        self.assertTrue(dist == "norm")
Esempio n. 4
0
 def test_rand_shape(self):
     m = rand(self.sds, rows=shape[0], cols=shape[1]).compute()
     self.assertTrue(m.shape == shape)
Esempio n. 5
0
 def test_rand_invalid_pdf(self):
     with self.assertRaises(ValueError) as context:
         rand(self.sds, rows=1, cols=10, pdf="norm").compute()
Esempio n. 6
0
 def test_rand_invalid_shape(self):
     with self.assertRaises(ValueError) as context:
         rand(self.sds, rows=1, cols=-10).compute()
Esempio n. 7
0
 def test_rand_zero_shape(self):
     m = rand(self.sds, rows=0, cols=0).compute()
     self.assertTrue(np.allclose(m, np.array([[]])))