コード例 #1
0
ファイル: test_synchronous.py プロジェクト: siyuzhou/Neet
 def test_timeseries_eca(self):
     rule = ECA(30)
     for size in [5, 7, 11]:
         landscape = Landscape(rule, size=size)
         time = 10
         series = landscape.timeseries(time)
         self.assertEqual((size, 2**size, time + 1), series.shape)
         for index, state in enumerate(rule.state_space(size)):
             traj = landscape.trajectory(state, timesteps=time)
             for t, expect in enumerate(traj):
                 got = series[:, index, t]
                 self.assertTrue(np.array_equal(expect, got))
コード例 #2
0
ファイル: test_synchronous.py プロジェクト: siyuzhou/Neet
    def test_is_state_space(self):
        self.assertTrue(issubclass(Landscape, StateSpace))

        space = s_pombe.state_space()
        landscape = Landscape(s_pombe)
        self.assertEqual(list(space), list(landscape))
        self.assertEqual([space.encode(state) for state in space],
                         list(map(landscape.encode, landscape)))

        ca = ECA(30)
        space = ca.state_space(10)
        landscape = Landscape(ca, size=10)
        self.assertEqual(list(space), list(landscape))
        self.assertEqual([space.encode(state) for state in space],
                         list(map(landscape.encode, landscape)))