Exemple #1
0
 def test_array_two_maps_p_mask_2(self):
     maps = Maps(Ni=1, Nj=3, Nk=3,
                 mask=self.mask).randomize(size=np.array([100, 0]),
                                           p=self.p)
     self.assertEqual(maps.to_array(0)[0, 0, 0], 0)
     self.assertEqual(maps.to_array(0)[0, 1, 1], 100)
     self.assertTrue(np.array_equal(maps.sum(axis=0), np.array([100, 0])))
Exemple #2
0
    def test_normalize_one_map(self):
        maps = Maps(self.array, Ni=self.Ni, Nj=self.Nj, Nk=self.Nk)
        maps_ = maps.normalize(inplace=False)
        maps.normalize(inplace=True)

        self.assertTrue(np.array_equal(maps.to_array(), self.expected))
        self.assertTrue(np.array_equal(maps_.to_array(), self.expected))
Exemple #3
0
    def test_one_map(self):
        maps = Maps(self.array, Ni=self.Ni, Nj=self.Nj, Nk=self.Nk)
        maps_ = maps.shuffle(inplace=False)
        maps.shuffle(inplace=True)

        self.assertTrue(np.array_equal(maps.to_array(), self.array))
        self.assertTrue(np.array_equal(maps_.to_array(), self.array))
Exemple #4
0
 def test_mask_init_one_map(self):
     maps = Maps(self.array,
                 Ni=self.Ni,
                 Nj=self.Nj,
                 Nk=self.Nk,
                 mask=self.mask)
     self.assertTrue(np.array_equal(maps.to_array(), self.expected))
Exemple #5
0
    def test_threshold_one_map(self):
        maps = Maps(self.array, Ni=self.Ni, Nj=self.Nj, Nk=self.Nk)
        maps_ = maps.threshold(2, inplace=False)
        maps.threshold(2, inplace=True)

        self.assertTrue(np.array_equal(maps.to_array(), self.expected))
        self.assertTrue(np.array_equal(maps_.to_array(), self.expected))
Exemple #6
0
 def test_array_two_maps_p_mask_override(self):
     maps = Maps(Ni=1, Nj=3, Nk=3,
                 mask=self.mask).randomize(size=np.array([50, 50]),
                                           p=self.p,
                                           override_mask=True)
     self.assertEqual(maps.to_array(0)[0, 0, 0], 0)
     self.assertTrue(np.array_equal(maps.sum(axis=0), np.array([50, 50])))
Exemple #7
0
    def test_random_state(self):
        maps = Maps(self.array2, Ni=self.Ni, Nj=self.Nj, Nk=self.Nk)
        maps_ = maps.shuffle(random_state=0, inplace=False)
        maps.shuffle(random_state=0, inplace=True)

        self.assertTrue(np.array_equal(maps.to_array(), maps_.to_array()))
Exemple #8
0
 def test_array_two_maps_p(self):
     maps = Maps(Ni=1, Nj=3, Nk=3).randomize(size=np.array([50, 50]),
                                             p=self.p)
     self.assertEqual(maps.to_array(0)[0, 0, 0], 0)
     self.assertTrue(np.array_equal(maps.sum(axis=0), np.array([50, 50])))
Exemple #9
0
 def test_two_maps_p_mask_override(self):
     maps = Maps(Ni=1, Nj=3, Nk=3,
                 mask=self.mask).randomize(size=(100, 2),
                                           p=self.p,
                                           override_mask=True)
     self.assertEqual(maps.to_array(0)[0, 0, 0], 0)
Exemple #10
0
 def test_two_maps_p_mask(self):
     maps = Maps(Ni=1, Nj=3, Nk=3, mask=self.mask).randomize(size=(100, 2),
                                                             p=self.p)
     self.assertEqual(maps.to_array(0)[0, 0, 0], 0)
     self.assertEqual(maps.summed_map().to_array()[0, 1, 1], 100)
Exemple #11
0
 def test_two_maps_p(self):
     maps = Maps(Ni=1, Nj=3, Nk=3).randomize(size=(100, 2), p=self.p)
     self.assertEqual(maps.to_array(0)[0, 0, 0], 0)