コード例 #1
0
ファイル: test_connectors.py プロジェクト: tclose/PyNN
 def test_with_n_larger_than_population_size_no_self_connections(self):
     C = connectors.FixedNumberPreConnector(n=7,
                                            allow_self_connections=False,
                                            rng=MockRNG(delta=1))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p2, self.p2, C, syn)
     self.assertEqual(
         prj.get(["weight", "delay"], format='list', gather=False
                 ),  # use gather False because we are faking the MPI
         [
             (0, 1, 0.0, 0.123),
             (2, 1, 0.0, 0.123),
             (3, 1, 0.0, 0.123),
             (4, 1, 0.0, 0.123),
             (4, 1, 0.0, 0.123),
             (3, 1, 0.0, 0.123),
             (2, 1, 0.0, 0.123),
             (0, 3, 0.0, 0.123),
             (1, 3, 0.0, 0.123),
             (2, 3, 0.0, 0.123),
             (4, 3, 0.0, 0.123),
             (4, 3, 0.0, 0.123),
             (2, 3, 0.0, 0.123),
             (1, 3, 0.0, 0.123),
         ])
コード例 #2
0
ファイル: test_connectors.py プロジェクト: tclose/PyNN
 def test_with_replacement_no_self_connections(self):
     C = connectors.FixedNumberPreConnector(n=3,
                                            with_replacement=True,
                                            allow_self_connections=False,
                                            rng=MockRNG(start=2, delta=1))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p2, self.p2, C, syn)
     self.assertEqual(
         prj.get(["weight", "delay"], format='list', gather=False
                 ),  # use gather False because we are faking the MPI
         [  #(2, 0, 0.0, 0.123),  # [2, 3, 4] --> [2, 3, 4]
             #(3, 0, 0.0, 0.123),
             #(4, 0, 0.0, 0.123),
             (0, 1, 0.0, 0.123),  # [0, 1, 2] --> [0, 3, 2]
             #(1, 1, 0.0, 0.123),
             (3, 1, 0.0, 0.123),
             (2, 1, 0.0, 0.123),
             #(4, 2, 0.0, 0.123),  # [4, 0, 1] --> [4, 0, 1]
             #(0, 2, 0.0, 0.123),
             #(1, 2, 0.0, 0.123),
             (2, 3, 0.0, 0.123),  # [2, 3, 4] --> [2, 0, 4]
             #(3, 3, 0.0, 0.123),
             (0, 3, 0.0, 0.123),
             (4, 3, 0.0, 0.123),
         ])
コード例 #3
0
 def test_with_replacement_with_neuron_0_connecting_neuron_0(self, sim=sim):
     n = random.RandomDistribution('binomial', (5, 0.5), rng=MockRNG3())
     C = connectors.FixedNumberPreConnector(
         n=n, with_replacement=True, rng=MockRNG(start=0, delta=1))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p1, self.p2, C, syn)
     self.assertEqual(prj.get(["weight", "delay"], format='list'),
                      [(0, 0, 0.0, 0.123),
                       ])
コード例 #4
0
 def test_with_n_smaller_than_population_size(self, sim=sim):
     C = connectors.FixedNumberPreConnector(n=3, rng=MockRNG(delta=1))
     syn = sim.StaticSynapse(weight="0.1*d")
     prj = sim.Projection(self.p1, self.p2, C, syn)
     self.assertEqual(prj.get(["weight", "delay"], format='list', gather=False),  # use gather False because we are faking the MPI
                      [(3, 1, 0.2, 0.123),
                       (2, 1, 0.1, 0.123),
                       (1, 1, 0.0, 0.123),
                       (3, 3, 0.0, 0.123),
                       (2, 3, 0.1, 0.123),
                       (1, 3, 0.2, 0.123), ])
コード例 #5
0
ファイル: test_connectors.py プロジェクト: p-muller/PyNN
 def test_no_replacement_parallel_unsafe(self):
     C = connectors.FixedNumberPreConnector(n=3, with_replacement=False, rng=MockRNG(delta=1, parallel_safe=False))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p1, self.p2, C, syn)
     self.assertEqual(prj.get(["weight", "delay"], format='list', gather=False),  # use gather False because we are faking the MPI
                      [(3, 1, 0.0, 0.123),
                       (2, 1, 0.0, 0.123),
                       (1, 1, 0.0, 0.123),
                       (3, 3, 0.0, 0.123),
                       (2, 3, 0.0, 0.123),
                       (1, 3, 0.0, 0.123),])
コード例 #6
0
 def test_with_replacement_with_variable_n(self, sim=sim):
     n = random.RandomDistribution('binomial', (5, 0.5), rng=MockRNG(start=1, delta=2))
     # should give (1, 3, 0, 2, 4)
     C = connectors.FixedNumberPreConnector(n=n, with_replacement=True, rng=MockRNG(delta=1))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p1, self.p2, C, syn)
     self.assertEqual(prj.get(["weight", "delay"], format='list', gather=False),  # use gather False because we are faking the MPI
                      [  # (0, 0, 0.0, 0.123),
         (1, 1, 0.0, 0.123),
         (2, 1, 0.0, 0.123),
         (3, 1, 0.0, 0.123),
         (0, 3, 0.0, 0.123),
         (1, 3, 0.0, 0.123)])
コード例 #7
0
ファイル: test_connectors.py プロジェクト: agravier/pynn
 def test_with_n_smaller_than_population_size(self):
     C = connectors.FixedNumberPreConnector(n=3)
     C.progressbar = Mock()
     C.progression = Mock()
     assert self.prj.rng is not None
     self.prj.post.local_cells = [
         MockCell(n) for n in self.prj.post.local_cells
     ]
     C.connect(self.prj)
     assert_equal(self.prj.connections, [(17, 80, 0.0, MIN_DELAY),
                                         (18, 80, 0.0, MIN_DELAY),
                                         (19, 80, 0.0, MIN_DELAY),
                                         (17, 82, 0.0, MIN_DELAY),
                                         (18, 82, 0.0, MIN_DELAY),
                                         (19, 82, 0.0, MIN_DELAY)])
コード例 #8
0
 def test_with_replacement(self, sim=sim):
     C = connectors.FixedNumberPreConnector(n=3, with_replacement=True, rng=MockRNG(delta=1))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p1, self.p2, C, syn)
     self.assertEqual(prj.get(["weight", "delay"], format='list', gather=False),  # use gather False because we are faking the MPI
                      [  # (0, 0, 0.0, 0.123),
         #(1, 0, 0.0, 0.123),
         #(2, 0, 0.0, 0.123),
         (3, 1, 0.0, 0.123),
         (0, 1, 0.0, 0.123),
         (1, 1, 0.0, 0.123),
         #(2, 2, 0.0, 0.123),
         #(3, 2, 0.0, 0.123),
         #(0, 2, 0.0, 0.123),
         (1, 3, 0.0, 0.123),
         (2, 3, 0.0, 0.123),
         (3, 3, 0.0, 0.123), ])
コード例 #9
0
 def test_with_replacement(self, sim=sim):
     C = connectors.FixedNumberPreConnector(n=3, with_replacement=True, rng=MockRNG(delta=1))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p1, self.p2, C, syn)
     self.assertEqual(prj.get(["weight", "delay"], format='list'),
                      [(0, 0, 0.0, 0.123),
                       (1, 0, 0.0, 0.123),
                       (2, 0, 0.0, 0.123),
                       (3, 1, 0.0, 0.123),
                       (0, 1, 0.0, 0.123),
                       (1, 1, 0.0, 0.123),
                       (2, 2, 0.0, 0.123),
                       (3, 2, 0.0, 0.123),
                       (0, 2, 0.0, 0.123),
                       (1, 3, 0.0, 0.123),
                       (2, 3, 0.0, 0.123),
                       (3, 3, 0.0, 0.123),
                       (0, 4, 0.0, 0.123),
                       (1, 4, 0.0, 0.123),
                       (2, 4, 0.0, 0.123), ])
コード例 #10
0
 def test_with_n_larger_than_population_size_no_self_connections(self, sim=sim):
     C = connectors.FixedNumberPreConnector(
         n=7, allow_self_connections=False, rng=MockRNG(delta=1))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p2, self.p2, C, syn)
     self.assertEqual(prj.get(["weight", "delay"], format='list'),
                      [(1, 0, 0.0, 0.123),
                       (2, 0, 0.0, 0.123),
                       (3, 0, 0.0, 0.123),
                       (4, 0, 0.0, 0.123),
                       (4, 0, 0.0, 0.123),
                       (3, 0, 0.0, 0.123),
                       (2, 0, 0.0, 0.123),
                       (0, 1, 0.0, 0.123),
                       (2, 1, 0.0, 0.123),
                       (3, 1, 0.0, 0.123),
                       (4, 1, 0.0, 0.123),
                       (4, 1, 0.0, 0.123),
                       (3, 1, 0.0, 0.123),
                       (2, 1, 0.0, 0.123),
                       (0, 2, 0.0, 0.123),
                       (1, 2, 0.0, 0.123),
                       (3, 2, 0.0, 0.123),
                       (4, 2, 0.0, 0.123),
                       (4, 2, 0.0, 0.123),
                       (3, 2, 0.0, 0.123),
                       (1, 2, 0.0, 0.123),
                       (0, 3, 0.0, 0.123),
                       (1, 3, 0.0, 0.123),
                       (2, 3, 0.0, 0.123),
                       (4, 3, 0.0, 0.123),
                       (4, 3, 0.0, 0.123),
                       (2, 3, 0.0, 0.123),
                       (1, 3, 0.0, 0.123),
                       (0, 4, 0.0, 0.123),
                       (1, 4, 0.0, 0.123),
                       (2, 4, 0.0, 0.123),
                       (3, 4, 0.0, 0.123),
                       (3, 4, 0.0, 0.123),
                       (2, 4, 0.0, 0.123),
                       (1, 4, 0.0, 0.123)])
コード例 #11
0
 def test_no_replacement_parallel_unsafe(self, sim=sim):
     C = connectors.FixedNumberPreConnector(
         n=3, with_replacement=False, rng=MockRNG(delta=1, parallel_safe=False))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p1, self.p2, C, syn)
     self.assertEqual(prj.get(["weight", "delay"], format='list'),
                      [(3, 0, 0.0, 0.123),
                       (2, 0, 0.0, 0.123),
                       (1, 0, 0.0, 0.123),
                       (3, 1, 0.0, 0.123),
                       (2, 1, 0.0, 0.123),
                       (1, 1, 0.0, 0.123),
                       (3, 2, 0.0, 0.123),
                       (2, 2, 0.0, 0.123),
                       (1, 2, 0.0, 0.123),
                       (3, 3, 0.0, 0.123),
                       (2, 3, 0.0, 0.123),
                       (1, 3, 0.0, 0.123),
                       (3, 4, 0.0, 0.123),
                       (2, 4, 0.0, 0.123),
                       (1, 4, 0.0, 0.123), ])
コード例 #12
0
 def test_no_replacement_no_self_connections(self, sim=sim):
     C = connectors.FixedNumberPreConnector(n=3, with_replacement=False,
                                            allow_self_connections=False, rng=MockRNG(start=2, delta=1))
     syn = sim.StaticSynapse()
     prj = sim.Projection(self.p2, self.p2, C, syn)
     self.assertEqual(prj.get(["weight", "delay"], format='list'),
                      [(4, 0, 0.0, 0.123),
                       (3, 0, 0.0, 0.123),
                       (2, 0, 0.0, 0.123),
                       (4, 1, 0.0, 0.123),
                       (3, 1, 0.0, 0.123),
                       (2, 1, 0.0, 0.123),
                       (4, 2, 0.0, 0.123),
                       (3, 2, 0.0, 0.123),
                       (1, 2, 0.0, 0.123),
                       (4, 3, 0.0, 0.123),
                       (2, 3, 0.0, 0.123),
                       (1, 3, 0.0, 0.123),
                       (3, 4, 0.0, 0.123),
                       (2, 4, 0.0, 0.123),
                       (1, 4, 0.0, 0.123)])
コード例 #13
0
 def test_with_n_smaller_than_population_size(self, sim=sim):
     C = connectors.FixedNumberPreConnector(n=3, rng=MockRNG(delta=1))
     syn = sim.StaticSynapse(weight="0.1*d")
     prj = sim.Projection(self.p1, self.p2, C, syn)
     rec = prj.get(["weight", "delay"], format='list')
     assert_array_almost_equal([list(r) for r in rec],
                               [(3, 0, 0.3, 0.123),
                                (2, 0, 0.2, 0.123),
                                (1, 0, 0.1, 0.123),
                                (3, 1, 0.2, 0.123),
                                (2, 1, 0.1, 0.123),
                                (1, 1, 0.0, 0.123),
                                (3, 2, 0.1, 0.123),
                                (2, 2, 0.0, 0.123),
                                (1, 2, 0.1, 0.123),
                                (3, 3, 0.0, 0.123),
                                (2, 3, 0.1, 0.123),
                                (1, 3, 0.2, 0.123),
                                (3, 4, 0.1, 0.123),
                                (2, 4, 0.2, 0.123),
                                (1, 4, 0.3, 0.123)])