예제 #1
0
    def test_ConnectPrePostWD(self):
        """Connect pre to post with a weight and delay"""

        # Connect([pre], [post], w, d)
        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 2)
        post = nest.Create("iaf_neuron", 2)
        nest.Connect(pre, post, 2.0, 2.0)
        connections = nest.FindConnections(pre)
        weights = nest.GetStatus(connections, "weight")
        self.assertEqual(weights, [2.0, 2.0])

        # Connect([pre], [post], [w], [d])
        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 2)
        post = nest.Create("iaf_neuron", 2)
        nest.Connect(pre, post, [2.0], [2.0])
        connections = nest.FindConnections(pre)
        weights = nest.GetStatus(connections, "weight")
        delays = nest.GetStatus(connections, "delay")
        self.assertEqual(weights, [2.0, 2.0])
        self.assertEqual(delays, [2.0, 2.0])

        # Connect([pre], [post], [w, w], [d, d])
        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 2)
        post = nest.Create("iaf_neuron", 2)
        nest.Connect(pre, post, [2.0, 3.0], [2.0, 3.0])
        connections = nest.FindConnections(pre)
        weights = nest.GetStatus(connections, "weight")
        delays = nest.GetStatus(connections, "delay")
        self.assertEqual(weights, [2.0, 3.0])
        self.assertEqual(delays, [2.0, 3.0])
예제 #2
0
    def test_ConnectPrePostParams(self):
        """Connect pre to post with a params dict"""

        # Connect([pre], [post], params)
        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 2)
        post = nest.Create("iaf_neuron", 2)
        nest.Connect(pre, post, {"weight": 2.0})
        connections = nest.FindConnections(pre)
        weights = nest.GetStatus(connections, "weight")
        self.assertEqual(weights, [2.0, 2.0])

        # Connect([pre], [post], [params])
        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 2)
        post = nest.Create("iaf_neuron", 2)
        nest.Connect(pre, post, [{"weight": 2.0}])
        connections = nest.FindConnections(pre)
        weights = nest.GetStatus(connections, "weight")
        self.assertEqual(weights, [2.0, 2.0])

        # Connect([pre], [post], [params, params])
        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 2)
        post = nest.Create("iaf_neuron", 2)
        nest.Connect(pre, post, [{"weight": 2.0}, {"weight": 3.0}])
        connections = nest.FindConnections(pre)
        weights = nest.GetStatus(connections, "weight")
        self.assertEqual(weights, [2.0, 3.0])
예제 #3
0
    def test_FindConnections(self):
        """FindConnections"""

        nest.ResetKernel()

        a = nest.Create("iaf_neuron", 3)
        nest.DivergentConnect(a, a)
        c1 = nest.FindConnections(a)
        c2 = nest.FindConnections(a, synapse_type="static_synapse")
        self.assertEqual(c1, c2)

        d1 = [{"weight": w} for w in [2.0, 3.0, 4.0]]

        c3 = nest.FindConnections(a, a)
        nest.SetStatus(c3, d1)
        s1 = nest.GetStatus(c3, "weight")
        self.assertEqual(s1, [w["weight"] for w in d1])
예제 #4
0
    def test_DivergentConnect(self):
        """DivergentConnect pre to post"""

        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 1)
        post = nest.Create("iaf_neuron", 3)
        nest.DivergentConnect(pre, post)
        connections = nest.FindConnections(pre)
        targets = nest.GetStatus(connections, "target")
        self.assertEqual(targets, post)
예제 #5
0
    def test_ConnectPrePost(self):
        """Connect pre to post"""

        # Connect([pre], [post])
        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 2)
        post = nest.Create("iaf_neuron", 2)
        nest.Connect(pre, post)
        connections = nest.FindConnections(pre)
        targets = nest.GetStatus(connections, "target")
        self.assertEqual(targets, post)
예제 #6
0
    def test_ConvergentConnect(self):
        """ConvergentConnect pre to post"""

        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 3)
        post = nest.Create("iaf_neuron", 1)
        nest.ConvergentConnect(pre, post)
        expected_targets = [post[0] for x in range(len(pre))]
        connections = nest.FindConnections(pre)
        targets = nest.GetStatus(connections, "target")
        self.assertEqual(expected_targets, targets)
예제 #7
0
    def test_DivergentConnectWD(self):
        """DivergentConnect pre to post with weight and delay"""

        nest.ResetKernel()
        pre = nest.Create("iaf_neuron", 1)
        post = nest.Create("iaf_neuron", 3)
        nest.DivergentConnect(pre,
                              post,
                              weight=[2.0, 2.0, 2.0],
                              delay=[1.0, 2.0, 3.0])
        connections = nest.FindConnections(pre)
        weights = nest.GetStatus(connections, "weight")
        delays = nest.GetStatus(connections, "delay")
        self.assertEqual(weights, [2.0, 2.0, 2.0])
        self.assertEqual(delays, [1.0, 2.0, 3.0])
예제 #8
0
    def test_ThreadsFindConnections(self):
        """FindConnections with threads"""

        # Test if we have a thread-enabled NEST
        nest.sr("statusdict /have_pthreads get")
        if not nest.spp(): return

        nest.ResetKernel()
        nest.SetKernelStatus({'local_num_threads': 8})
        pre = nest.Create("iaf_neuron")
        post = nest.Create("iaf_neuron", 6)

        nest.DivergentConnect(pre, post)

        conn = nest.FindConnections(pre)
        targets = nest.GetStatus(conn, "target")

        self.assertEqual(targets, post)