本文整理汇总了Python中pyNN.mock.setup函数的典型用法代码示例。如果您正苦于以下问题:Python setup函数的具体用法?Python setup怎么用?Python setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
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
示例2: setUp
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
示例3: test_current_time_two_runs
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()
示例4: setUp
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))
示例5: setUp
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()
示例6: setUp
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)
示例7: test_callbacks
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)))
示例8: test_reset
def test_reset(self):
sim.setup()
sim.run(1000.0)
sim.reset()
self.assertEqual(sim.get_current_time(), 0.0)
示例9: setUp
def setUp(self, sim=sim, **extra):
self.MIN_DELAY = 0.123
sim.setup(num_processes=2, rank=1, min_delay=0.123, **extra)
示例10: test_max_delay
def test_max_delay(self):
sim.setup(max_delay=9.87)
self.assertEqual(sim.get_max_delay(), 9.87)
示例11: test_end
def test_end(self, sim=sim):
sim.setup(**self.extra)
sim.end() # need a better test
示例12: test_run
def test_run(self):
sim.setup()
self.assertEqual(sim.run(1000.0), 1000.0)
self.assertEqual(sim.run(1000.0), 2000.0)
示例14: test_end
def test_end(self):
sim.setup()
sim.end() # need a better test
示例15: test_min_delay
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()