Esempio n. 1
0
 def setUp(self):
     g = GhostSpecie()
     b = Specie("B")
     self.sites = [[[b, b], [g, g]], [[b, g], [g, b]]]
     self.sg = SitesGrid(self.sites)
     self.allg0 = SitesGrid.sea(2, 2, 2, GhostSpecie())
     self.allg = SitesGrid.sea(4, 2, 2, GhostSpecie())
Esempio n. 2
0
 def __init__(self, goal_num):
     self.goal_num = goal_num
     m = [[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]]
     self.delta = 2.1  # the distance threshold to collect neighbors
     sg = SitesGrid([[[GhostSpecie() for _ in range(goal_num)]
                      for _ in range(goal_num)] for _ in range(goal_num)])
     self.bg = CStru(m, sg)
     self.start_position = self.bg.get_midpoint()
Esempio n. 3
0
    def setUp(self):
        self.m = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
        g = GhostSpecie()
        b = Specie("B")
        self.sites = [[[g, b], [g, g]], [[b, b], [b, g]]]

        self.arr = np.array([0, 5, 0, 0, 5, 5, 5, 0]).reshape([2, 2, 2])
        self.sg = SitesGrid(self.sites)
        self.s = CStru(self.m, self.sg)
Esempio n. 4
0
    def test_equal(self):
        m_0 = [[1, 1, 1], [0, 0, 1], [1, 0, 0]]
        g = GhostSpecie()
        b = Specie("B")
        sites_0 = [[[b, b], [g, g]], [[b, g], [g, b]]]
        sg_0 = SitesGrid(sites_0)

        diff_m = CStru(m_0, self.sg)
        diff_s = CStru(self.m, sg_0)
        self.assertEqual(self.s, self.s)
        self.assertNotEqual(diff_m, self.s)
        self.assertNotEqual(diff_s, self.s)
Esempio n. 5
0
    def test_is_speckle_disjunct(self):
        g = GhostSpecie()
        b = Specie('B')
        m = [[0, 0, 20],
             [1, 0, 0],
             [0.5, 0.8660254, 0]]
        # ele_sea = SitesGrid.sea(4, 4, 1, b)
        # cell_mother_stru = CStru(m, ele_sea).get_cell()
        # sym = get_symmetry(cell_mother_stru, symprec=1e-3)
        # ops = [(r, t) for r, t in zip(sym['rotations'], sym['translations'])]

        sites_0 = [[[g, g, b, b],
                    [b, b, b, b],
                    [b, b, b, b],
                    [b, b, b, b]]]
        sg_0 = SitesGrid(sites_0)
        cstru00 = CStru(m, sg_0)

        self.assertFalse(sogen.is_speckle_disjunct(cstru00, g))

        sites_1 = [[[g, b, b, g],
                    [b, b, b, b],
                    [b, b, b, b],
                    [b, b, b, b]]]
        sg_1 = SitesGrid(sites_1)
        cstru01 = CStru(m, sg_1)

        self.assertFalse(sogen.is_speckle_disjunct(cstru01, g))


        sites_2 = [[[g, b, b, b],
                    [b, g, b, b],
                    [b, b, b, b],
                    [b, b, b, b]]]
        sg_2 = SitesGrid(sites_2)
        cstru02 = CStru(m, sg_2)

        self.assertTrue(sogen.is_speckle_disjunct(cstru02, g))
Esempio n. 6
0
 def test_random_fill(self):
     r = SitesGrid.random_fill(GhostSpecie(), (2, 2, 2), Specie("B"))
     self.assertIn(r.to_array().sum(), [5 * x for x in range(9)])
Esempio n. 7
0
    def test_get(self):
        self.assertEqual(self.sg[0, 1, 1], GhostSpecie())

        self.sg[0, 1, 1] = Specie("B")
        self.assertEqual(self.sg[0, 1, 1], Specie("B"))
Esempio n. 8
0
    def sea(cls, depth, width, length, sp=GhostSpecie()):
        sites = [[[sp for _ in range(length)] for _ in range(width)]
                 for _ in range(depth)]

        return cls(sites)