Пример #1
0
 def test_dict_roundtrip(self):
     s = Simulation()
     d = s.to_dict()
     self.assertTrue('MODEL_VERSION' in d)
     s2 = Simulation()
     s2.from_dict(d)
     self.assertEqual(s.ticks, s2.ticks)
     self.assertEqual(s.neighbors, s2.neighbors)
Пример #2
0
    def test_network_no_self_loops(self):
        """ an agent can't have itself as a neighbor.

        this means zeros in the adjacency matrix"""
        s = Simulation(number_agents=10)
        neighbors = nx.to_numpy_matrix(s.neighbors).tolist()
        for i in range(10):
            self.assertEquals(neighbors[i][i], 0)
Пример #3
0
 def test_dict_roundtrip(self):
     s = Simulation()
     d = s.to_dict()
     self.assertTrue('MODEL_VERSION' in d)
     s2 = Simulation()
     s2.from_dict(d)
     self.assertEqual(s.ticks, s2.ticks)
     self.assertEqual(s.neighbors, s2.neighbors)
Пример #4
0
    def test_setup_patches(self):
        s = Simulation(grid_size=10)
        shape = (10, 10)
        self.assertEquals(s.recreation_activity.shape, shape)
        self.assertEquals(s.domestic_activity.shape, shape)
        self.assertEquals(s.transport_activity.shape, shape)
        self.assertEquals(s.education_activity.shape, shape)

        self.assertEquals(s.food_exposure.shape, shape)
        self.assertEquals(s.energy_density.shape, shape)
        self.assertEquals(s.food_advertising.shape, shape)
        self.assertEquals(s.food_convenience.shape, shape)
        self.assertEquals(s.food_literacy.shape, shape)
Пример #5
0
 def test_tick(self):
     s = Simulation()
     self.assertEqual(s.ticks, 0)
     s.tick()
     self.assertEqual(s.ticks, 1)
Пример #6
0
 def test_tick(self):
     s = Simulation()
     self.assertEqual(s.ticks, 0)
     s.tick()
     self.assertEqual(s.ticks, 1)
Пример #7
0
 def test_setup_network(self):
     s = Simulation(number_agents=10)
     self.assertEquals(nx.to_numpy_matrix(s.neighbors).shape, (10, 10))
Пример #8
0
 def test_setup_agents_odd_number(self):
     # this test is here because networkx.random_regular_graph
     # requires n * d to be even. so we make sure that we adjust
     # beforehand
     s = Simulation(number_agents=5)
     self.assertEquals(len(s.agents_mass), 5)
Пример #9
0
 def test_setup_agents(self):
     s = Simulation(number_agents=10)
     self.assertEquals(len(s.agents_mass), 10)
     self.assertEquals(len(s.agents_base_output), 10)
Пример #10
0
 def test_creation(self):
     s = Simulation()
     self.assertTrue(s is not None)