コード例 #1
0
 def test_current_time_two_runs(self, sim=sim):
     sim.setup(timestep=0.1, **self.extra)
     sim.run(10.1)
     self.assertAlmostEqual(sim.get_current_time(), 10.1)
     sim.run(23.4)
     self.assertAlmostEqual(sim.get_current_time(), 33.5)
     sim.end()
コード例 #2
0
ファイル: test_connectors.py プロジェクト: muffgaga/PyNN
 def setUp(self):
     sim.setup(num_processes=2, rank=1, min_delay=0.123)
     self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line())
     self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
     assert_array_equal(self.p2._mask_local, numpy.array([0,1,0,1,0], dtype=bool))
     random.mpi_rank = 1
     random.num_processes = 2
コード例 #3
0
    def test_callbacks(self, sim=sim):
        total_time = 100.
        callback_steps = [10., 10., 20., 25.]

        # callbacks are called at 0. and after every step
        expected_callcount = [11, 11, 6, 5]
        num_callbacks = len(callback_steps)
        callback_callcount = [0] * num_callbacks

        def make_callback(idx):
            def callback(time):
                callback_callcount[idx] += 1
                return time + callback_steps[idx]

            return callback

        callbacks = [make_callback(i) for i in range(num_callbacks)]
        sim.setup(timestep=0.1, min_delay=0.1, **self.extra)
        sim.run_until(total_time, callbacks=callbacks)

        self.assertTrue(
            all(callback_callcount[i] == expected_callcount[i]
                for i in range(num_callbacks)))

        sim.end()
コード例 #4
0
 def test_current_time_two_runs(self, sim=sim):
     sim.setup(timestep=0.1, **self.extra)
     sim.run(10.1)
     self.assertAlmostEqual(sim.get_current_time(), 10.1)
     sim.run(23.4)
     self.assertAlmostEqual(sim.get_current_time(), 33.5)
     sim.end()
コード例 #5
0
ファイル: test_connectors.py プロジェクト: tclose/PyNN
    def setUp(self):
        sim.setup(num_processes=2, rank=1, min_delay=0.123)
        self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line())
        self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
        assert_array_equal(self.p2._mask_local,
                           numpy.array([0, 1, 0, 1, 0], dtype=bool))
        connection_list = [
            (0, 0, 0.0, 1.0),
            (3, 0, 0.0, 1.0),
            (2, 3, 0.0, 1.0),  # local
            (2, 2, 0.0, 1.0),
            (0, 1, 0.0, 1.0),  # local
        ]
        list_connector = connectors.FromListConnector(connection_list)
        syn = sim.StaticSynapse()
        self.ref_prj = sim.Projection(self.p1, self.p2, list_connector, syn)
        self.orig_gather_dict = recording.gather_dict  # create reference to original function

        # The gather_dict function in recording needs to be temporarily replaced so it can work with
        # a mock version of the function to avoid it throwing an mpi4py import error when setting
        # the rank in pyNN.mock by hand to > 1
        def mock_gather_dict(D, all=False):
            return D

        recording.gather_dict = mock_gather_dict
コード例 #6
0
 def setUp(self):
     sim.setup(num_processes=2, rank=1, min_delay=0.123)
     self.p1 = sim.Population(9, sim.IF_cond_exp(),
                              structure=space.Grid2D(aspect_ratio=1.0, dx=1.0, dy=1.0))
     self.p2 = sim.Population(9, sim.HH_cond_exp(),
                              structure=space.Grid2D(aspect_ratio=1.0, dx=1.0, dy=1.0))
     assert_array_equal(self.p2._mask_local, numpy.array([1, 0, 1, 0, 1, 0, 1, 0, 1], dtype=bool))
コード例 #7
0
ファイル: test_connectors.py プロジェクト: sbillaudelle/PyNN
 def setUp(self):
     sim.setup(num_processes=2, rank=1, min_delay=0.123)
     self.p1 = sim.Population(9, sim.IF_cond_exp(), 
                              structure=space.Grid2D(aspect_ratio=1.0, dx=1.0, dy=1.0))
     self.p2 = sim.Population(9, sim.HH_cond_exp(), 
                              structure=space.Grid2D(aspect_ratio=1.0, dx=1.0, dy=1.0))
     assert_array_equal(self.p2._mask_local, numpy.array([1,0,1,0,1,0,1,0,1], dtype=bool))
コード例 #8
0
ファイル: test_connectors.py プロジェクト: jougs/PyNN
    def setUp(self):
        sim.setup(num_processes=2, rank=1, min_delay=0.123)
        self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line())
        self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
        assert_array_equal(self.p2._mask_local,
                           numpy.array([0, 1, 0, 1, 0], dtype=bool))
        connection_list = [
            (0, 0, 0.0, 1.0),
            (3, 0, 0.0, 1.0),
            (2, 3, 0.0, 1.0),  # local
            (2, 2, 0.0, 1.0),
            (0, 1, 0.0, 1.0),  # local
        ]
        list_connector = connectors.FromListConnector(connection_list)
        syn = sim.StaticSynapse()
        self.ref_prj = sim.Projection(self.p1, self.p2, list_connector, syn)
        self.orig_gather_dict = recording.gather_dict  # create reference to original function

        # The gather_dict function in recording needs to be temporarily replaced so it can work with
        # a mock version of the function to avoid it throwing an mpi4py import error when setting
        # the rank in pyNN.mock by hand to > 1
        def mock_gather_dict(D, all=False):
            return D

        recording.gather_dict = mock_gather_dict
コード例 #9
0
 def setUp(self, sim=sim, **extra):
     sim.setup(num_processes=2, rank=1, min_delay=0.123, **extra)
     self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line())
     self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
     assert_array_equal(self.p1._mask_local,
                        np.array([0, 1, 0, 1], dtype=bool))
     assert_array_equal(self.p2._mask_local,
                        np.array([0, 1, 0, 1, 0], dtype=bool))
コード例 #10
0
ファイル: test_projection.py プロジェクト: sbillaudelle/PyNN
 def setUp(self):
     sim.setup()
     self.p1 = sim.Population(7, sim.IF_cond_exp())
     self.p2 = sim.Population(4, sim.IF_cond_exp())
     self.p3 = sim.Population(5, sim.IF_curr_alpha())
     self.syn1 = sim.StaticSynapse(weight=0.123, delay=0.5)
     self.random_connect = sim.FixedNumberPostConnector(n=2)
     self.syn2 = sim.StaticSynapse(weight=0.456, delay=0.4)
     self.all2all = sim.AllToAllConnector()
コード例 #11
0
 def setUp(self):
     sim.setup()
     self.p1 = sim.Population(7, sim.IF_cond_exp())
     self.p2 = sim.Population(4, sim.IF_cond_exp())
     self.p3 = sim.Population(5, sim.IF_curr_alpha())
     self.syn1 = sim.StaticSynapse(weight=0.123, delay=0.5)
     self.random_connect = sim.FixedNumberPostConnector(n=2)
     self.syn2 = sim.StaticSynapse(weight=0.456, delay=0.4)
     self.all2all = sim.AllToAllConnector()
コード例 #12
0
ファイル: test_projection.py プロジェクト: tclose/PyNN
 def setUp(self, sim=sim, **extra):
     sim.setup(**extra)
     self.p1 = sim.Population(7, sim.IF_cond_exp())
     self.p2 = sim.Population(4, sim.IF_cond_exp())
     self.p3 = sim.Population(5, sim.IF_curr_alpha())
     self.syn1 = sim.StaticSynapse(weight=0.006, delay=0.5)
     self.random_connect = sim.FixedNumberPostConnector(n=2)
     self.syn2 = sim.StaticSynapse(weight=0.012, delay=0.4)
     self.all2all = sim.AllToAllConnector()
     self.syn3 = sim.TsodyksMarkramSynapse(weight=0.012, delay=0.6, U=0.2, tau_rec=50)
コード例 #13
0
 def setUp(self, sim=sim, **extra):
     sim.setup(**extra)
     self.p1 = sim.Population(7, sim.IF_cond_exp())
     self.p2 = sim.Population(4, sim.IF_cond_exp())
     self.p3 = sim.Population(5, sim.IF_curr_alpha())
     self.syn1 = sim.StaticSynapse(weight=0.006, delay=0.5)
     self.random_connect = sim.FixedNumberPostConnector(n=2)
     self.syn2 = sim.StaticSynapse(weight=0.012, delay=0.4)
     self.all2all = sim.AllToAllConnector()
     self.syn3 = sim.TsodyksMarkramSynapse(weight=0.012, delay=0.6, U=0.2, tau_rec=50)
コード例 #14
0
 def setUp(self, sim=sim, **extra):
     sim.setup(min_delay=0.123, **extra)
     self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line())
     self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
     self.connection_list = [
         (0, 0, 0.1, 0.1),
         (3, 0, 0.2, 0.11),
         (2, 3, 0.3, 0.12),  # local
         (2, 2, 0.4, 0.13),
         (0, 1, 0.5, 0.14),  # local
     ]
コード例 #15
0
ファイル: test_connectors.py プロジェクト: sbillaudelle/PyNN
 def setUp(self):
     sim.setup(num_processes=2, rank=1, min_delay=0.123)
     self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line())
     self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
     assert_array_equal(self.p2._mask_local, numpy.array([0,1,0,1,0], dtype=bool))
     self.connection_list = [
         (0, 0, 0.1, 0.1),
         (3, 0, 0.2, 0.11),
         (2, 3, 0.3, 0.12),  # local
         (2, 2, 0.4, 0.13),
         (0, 1, 0.5, 0.14),  # local
         ]
コード例 #16
0
 def setUp(self):
     sim.setup(num_processes=2, rank=1, min_delay=0.123)
     self.p1 = sim.Population(4, sim.IF_cond_exp(), structure=space.Line())
     self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
     assert_array_equal(self.p2._mask_local, numpy.array([0, 1, 0, 1, 0], dtype=bool))
     self.connection_list = [
         (0, 0, 0.1, 0.1),
         (3, 0, 0.2, 0.11),
         (2, 3, 0.3, 0.12),  # local
         (2, 2, 0.4, 0.13),
         (0, 1, 0.5, 0.14),  # local
         ]
コード例 #17
0
 def setUp(self, sim=sim, **extra):
     self.MIN_DELAY = 0.123
     sim.setup(num_processes=2, rank=1, min_delay=self.MIN_DELAY, **extra)
     self.p1 = sim.Population(7, sim.IF_cond_exp())
     self.p2 = sim.Population(4, sim.IF_cond_exp())
     self.p3 = sim.Population(5, sim.IF_curr_alpha())
     self.projections = {"cond": {}, "curr": {}}
     for psr, post in (("cond", self.p2), ("curr", self.p3)):
         for rt in ("excitatory", "inhibitory"):
             self.projections[psr][rt] = sim.Projection(
                 self.p1,
                 post,
                 sim.AllToAllConnector(safe=True),
                 sim.StaticSynapse(),
                 receptor_type=rt)
コード例 #18
0
ファイル: test_simulation_control.py プロジェクト: jougs/PyNN
    def test_callbacks(self):
        total_time = 100.
        callback_steps = [10., 10., 20., 25.]

        # callbacks are called at 0. and after every step
        expected_callcount = [11, 11, 6, 5]
        num_callbacks = len(callback_steps)
        callback_callcount = [0] * num_callbacks

        def make_callback(idx):
            def callback(time):
                callback_callcount[idx] += 1
                return time + callback_steps[idx]
            return callback

        callbacks = [make_callback(i) for i in range(num_callbacks)]
        sim.setup(timestep=0.1, min_delay=0.1)
        sim.run_until(total_time, callbacks=callbacks)

        self.assertTrue(all(callback_callcount[i] == expected_callcount[i]
            for i in range(num_callbacks)))
コード例 #19
0
ファイル: test_simulation_control.py プロジェクト: jougs/PyNN
 def test_reset(self):
     sim.setup()
     sim.run(1000.0)
     sim.reset()
     self.assertEqual(sim.get_current_time(), 0.0)
コード例 #20
0
 def test_reset(self, sim=sim):
     sim.setup(**self.extra)
     sim.run(100.0)
     sim.reset()
     self.assertEqual(sim.get_current_time(), 0.0)
     sim.end()
コード例 #21
0
ファイル: test_population.py プロジェクト: jougs/PyNN
 def setUp(self):
     sim.setup()
コード例 #22
0
 def test_time_step(self, sim=sim):
     sim.setup(0.123, min_delay=0.246, **self.extra)
     self.assertAlmostEqual(sim.get_time_step(), 0.123)
     sim.end()
コード例 #23
0
 def setUp(self, sim=sim, **extra):
     self.MIN_DELAY = 0.123
     sim.setup(num_processes=2, rank=1, min_delay=0.123, **extra)
コード例 #24
0
ファイル: test_simulation_control.py プロジェクト: jougs/PyNN
 def test_min_delay(self):
     sim.setup(0.123, min_delay=0.246)
     self.assertEqual(sim.get_min_delay(), 0.246)
コード例 #25
0
 def test_run_twice(self, sim=sim):
     sim.setup(**self.extra)
     self.assertAlmostEqual(sim.run(100.0), 100.0)
     self.assertAlmostEqual(sim.run(100.0), 200.0)
     sim.end()
コード例 #26
0
 def test_reset(self, sim=sim):
     sim.setup(**self.extra)
     sim.run(100.0)
     sim.reset()
     self.assertEqual(sim.get_current_time(), 0.0)
     sim.end()
コード例 #27
0
 def test_max_delay(self, sim=sim):
     sim.setup(max_delay=9.87, **self.extra)
     self.assertAlmostEqual(sim.get_max_delay(), 9.87)
     sim.end()
コード例 #28
0
 def test_end(self, sim=sim):
     sim.setup(**self.extra)
     sim.end() # need a better test
コード例 #29
0
 def test_current_time(self):
     sim.setup(timestep=0.1)
     sim.run(10.1)
     self.assertEqual(sim.get_current_time(), 10.1)
     sim.run(23.4)
     self.assertEqual(sim.get_current_time(), 33.5)
コード例 #30
0
 def test_max_delay(self):
     sim.setup(max_delay=9.87)
     self.assertEqual(sim.get_max_delay(), 9.87)
コード例 #31
0
 def test_min_delay(self, sim=sim):
     sim.setup(0.123, min_delay=0.246, **self.extra)
     self.assertEqual(sim.get_min_delay(), 0.246)
     sim.end()
コード例 #32
0
ファイル: test_simulation_control.py プロジェクト: jougs/PyNN
 def test_current_time(self):
     sim.setup(timestep=0.1)
     sim.run(10.1)
     self.assertEqual(sim.get_current_time(), 10.1)
     sim.run(23.4)
     self.assertEqual(sim.get_current_time(), 33.5)
コード例 #33
0
ファイル: test_connectors.py プロジェクト: muffgaga/PyNN
 def setUp(self):
     self.MIN_DELAY = 0.123
     sim.setup(num_processes=2, rank=1, min_delay=0.123)
コード例 #34
0
ファイル: test_simulation_control.py プロジェクト: jougs/PyNN
 def test_time_step(self):
     sim.setup(0.123, min_delay=0.246)
     self.assertEqual(sim.get_time_step(), 0.123)
コード例 #35
0
 def test_run(self):
     sim.setup()
     self.assertEqual(sim.run(1000.0), 1000.0)
     self.assertEqual(sim.run(1000.0), 2000.0)
コード例 #36
0
ファイル: test_simulation_control.py プロジェクト: jougs/PyNN
 def test_max_delay(self):
     sim.setup(max_delay=9.87)
     self.assertEqual(sim.get_max_delay(), 9.87)
コード例 #37
0
 def test_reset(self):
     sim.setup()
     sim.run(1000.0)
     sim.reset()
     self.assertEqual(sim.get_current_time(), 0.0)
コード例 #38
0
 def setUp(self, sim=sim, **extra):
     sim.setup(num_processes=2, rank=1, min_delay=0.123, **extra)
     self.p1 = sim.Population(5, sim.IF_cond_exp(), structure=space.Line())
     self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
     assert_array_equal(self.p2._mask_local, numpy.array([1,0,1,0,1], dtype=bool))
コード例 #39
0
 def test_end(self, sim=sim):
     sim.setup(**self.extra)
     sim.end()  # need a better test
コード例 #40
0
 def test_min_delay(self, sim=sim):
     sim.setup(0.123, min_delay=0.246, **self.extra)
     self.assertEqual(sim.get_min_delay(), 0.246)
     sim.end()
コード例 #41
0
 def test_time_step(self):
     sim.setup(0.123, min_delay=0.246)
     self.assertEqual(sim.get_time_step(), 0.123)
コード例 #42
0
 def setUp(self, sim=sim, **extra):
     sim.setup(**extra)
     self.p1 = sim.Population(5, sim.IF_cond_exp())
     self.p2 = sim.Population(5, sim.HH_cond_exp())
コード例 #43
0
 def setUp(self):
     sim.setup()
コード例 #44
0
 def setUp(self, sim=sim, **extra):
     sim.setup(nmin_delay=0.123, **extra)
     self.p1 = sim.Population(5, sim.IF_cond_exp(), structure=space.Line())
     self.p2 = sim.Population(5, sim.HH_cond_exp(), structure=space.Line())
コード例 #45
0
 def test_min_delay(self):
     sim.setup(0.123, min_delay=0.246)
     self.assertEqual(sim.get_min_delay(), 0.246)
コード例 #46
0
ファイル: test_simulation_control.py プロジェクト: jougs/PyNN
 def test_run(self):
     sim.setup()
     self.assertEqual(sim.run(1000.0), 1000.0)
     self.assertEqual(sim.run(1000.0), 2000.0)
コード例 #47
0
 def test_run_twice(self, sim=sim):
     sim.setup(**self.extra)
     self.assertAlmostEqual(sim.run(100.0), 100.0)
     self.assertAlmostEqual(sim.run(100.0), 200.0)
     sim.end()
コード例 #48
0
ファイル: test_assembly.py プロジェクト: stjordanis/PyNN
 def setUp(self, sim=sim, **extra):
     sim.setup(**extra)
コード例 #49
0
 def test_max_delay(self, sim=sim):
     sim.setup(max_delay=9.87, **self.extra)
     self.assertAlmostEqual(sim.get_max_delay(), 9.87)
     sim.end()
コード例 #50
0
ファイル: test_connectors.py プロジェクト: muffgaga/PyNN
 def setUp(self):
     sim.setup(num_processes=2, rank=0)
     self.p1 = sim.Population(5, sim.IF_cond_exp())
     self.p2 = sim.Population(5, sim.HH_cond_exp())
     assert_array_equal(self.p2._mask_local, numpy.array([0,1,0,1,0], dtype=bool))
コード例 #51
0
ファイル: test_simulation_control.py プロジェクト: jougs/PyNN
 def test_end(self):
     sim.setup()
     sim.end() # need a better test
コード例 #52
0
 def test_time_step(self, sim=sim):
     sim.setup(0.123, min_delay=0.246, **self.extra)
     self.assertAlmostEqual(sim.get_time_step(), 0.123)
     sim.end()
コード例 #53
0
 def test_end(self):
     sim.setup()
     sim.end()  # need a better test