31
31
import pandas as pd
32
32
import pandas .testing as pdtest
33
33
import pytest
34
+ from testutil import expected_synapse_counts , synapse_counts
34
35
35
36
36
37
@pytest .fixture (autouse = True )
@@ -60,15 +61,10 @@ def test_get_connections_with_node_collection_step():
60
61
nodes = nest .Create ("iaf_psc_alpha" , 3 )
61
62
nest .Connect (nodes , nodes )
62
63
63
- conns = nest .GetConnections (nodes [::2 ])
64
- actual_sources = conns .get ("source" )
65
- actual_targets = conns .get ("target" )
66
-
67
- expected_sources = [1 , 1 , 1 , 3 , 3 , 3 ]
68
- expected_targets = [1 , 2 , 3 , 1 , 2 , 3 ]
64
+ actual = synapse_counts (nest .GetConnections (nodes [::2 ]), criteria = ["source" , "target" ])
65
+ expected = expected_synapse_counts (sources = [1 , 1 , 1 , 3 , 3 , 3 ], targets = [1 , 2 , 3 , 1 , 2 , 3 ])
69
66
70
- assert actual_sources == expected_sources
71
- assert actual_targets == expected_targets
67
+ assert actual == expected
72
68
73
69
74
70
def test_get_connections_with_sliced_node_collection ():
@@ -77,11 +73,10 @@ def test_get_connections_with_sliced_node_collection():
77
73
nodes = nest .Create ("iaf_psc_alpha" , 11 )
78
74
nest .Connect (nodes , nodes )
79
75
80
- conns = nest .GetConnections (nodes [1 :9 :3 ])
81
- actual_sources = conns . get ( "source" )
76
+ actual = synapse_counts ( nest .GetConnections (nodes [1 :9 :3 ]), criteria = [ "source" ])
77
+ expected = expected_synapse_counts ( sources = [ 2 ] * 11 + [ 5 ] * 11 + [ 8 ] * 11 )
82
78
83
- expected_sources = [2 ] * 11 + [5 ] * 11 + [8 ] * 11
84
- assert actual_sources == expected_sources
79
+ assert actual == expected
85
80
86
81
87
82
def test_get_connections_with_sliced_node_collection_2 ():
@@ -91,11 +86,10 @@ def test_get_connections_with_sliced_node_collection_2():
91
86
nest .Connect (nodes , nodes )
92
87
93
88
# ([ 2 3 4 ] + [ 8 9 10 11 ])[::3] -> [2 8 11]
94
- conns = nest .GetConnections ((nodes [1 :4 ] + nodes [7 :])[::3 ])
95
- actual_sources = conns . get ( "source" )
89
+ actual = synapse_counts ( nest .GetConnections ((nodes [1 :4 ] + nodes [7 :])[::3 ]), criteria = [ "source" ])
90
+ expected = expected_synapse_counts ( sources = [ 2 ] * 11 + [ 8 ] * 11 + [ 11 ] * 11 )
96
91
97
- expected_sources = [2 ] * 11 + [8 ] * 11 + [11 ] * 11
98
- assert actual_sources == expected_sources
92
+ assert actual == expected
99
93
100
94
101
95
def test_get_connections_bad_source_raises ():
@@ -111,11 +105,17 @@ def test_get_connections_bad_source_raises():
111
105
def test_get_connections_correct_table_with_node_collection_step ():
112
106
"""
113
107
Test that ``GetConnections`` table from ``NodeCollection`` sliced in step match expectations.
108
+
109
+ This test is for internal testing also of the synapse sorting process. It therefore requires
110
+ that the connection infrastructure has been updated before connections are read out.
114
111
"""
115
112
116
113
nodes = nest .Create ("iaf_psc_alpha" , 3 )
117
114
nest .Connect (nodes , nodes )
118
115
116
+ # Force synapse sorting
117
+ nest .Simulate (0.1 )
118
+
119
119
conns = nest .GetConnections (nodes [::2 ])
120
120
actual_row = [
121
121
conns .get ("source" )[3 ],
@@ -134,11 +134,17 @@ def test_get_connections_correct_table_with_node_collection_step():
134
134
def test_get_connections_correct_table_with_node_collection_index ():
135
135
"""
136
136
Test that ``GetConnections`` table from ``NodeCollection`` index match expectations.
137
+
138
+ This test is for internal testing also of the synapse sorting process. It therefore requires
139
+ that the connection infrastructure has been updated before connections are read out.
137
140
"""
138
141
139
142
nodes = nest .Create ("iaf_psc_alpha" , 3 )
140
143
nest .Connect (nodes , nodes )
141
144
145
+ # Force synapse sorting
146
+ nest .Simulate (0.1 )
147
+
142
148
actual_conns = pd .DataFrame (
143
149
nest .GetConnections (nodes [0 ]).get (["source" , "target" , "target_thread" , "synapse_id" , "port" ])
144
150
)
0 commit comments