forked from nest/nest-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_connect.sli
217 lines (184 loc) · 6.29 KB
/
test_connect.sli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* test_connect.sli
*
* This file is part of NEST.
*
* Copyright (C) 2004 The NEST Initiative
*
* NEST is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* NEST is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NEST. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* BeginDocumentation
Name: testsuite::test_connect - SLI script to test runability of all Connect variants
Synopsis: (test_connect) run
Description:
Tests if all variants of Connect can be run. This test checks the
outcome of the calls only in a minimal way. A more comprehensive
set of tests is available in PyNEST. It also checks the given
parameters more thoroughly and looks at statistics of the resulting
connectivity.
FirstVersion: April 2014
Author: Jochen Martin Eppler
SeeAlso: Connect
*/
M_ERROR setverbosity
(unittest) run
/unittest using
(Running Connect tests with argument type ') 1 type cvs join (') join =
( Testing variant "integer integer") =
ResetKernel
/iaf_neuron 2 Create ;
1 2 Connect
<< /source [1] >> GetConnections 0 get
/target get 2 eq assert_or_die
( Testing variant "integer integer double double") =
ResetKernel
/iaf_neuron 2 Create ;
1 2 2.0 3.0 Connect
<< /source [1] >> GetConnections 0 get dup dup
/target get 2 eq assert_or_die
/weight get 2.0 eq assert_or_die
/delay get 3.0 eq assert_or_die
% We can run the tests for TokenArray, IntVectorDatum and
% GIDCollectionDatum in a loop using arrayload
[ [[1 2 3] [4 5 6] ]
[[1 2 3] cv_iv [4 5 6] cv_iv ]
[1 3 cvgidcollection 4 6 cvgidcollection]] {
/addresses Set
(Running Connect tests with argument type ') addresses 0 get type cvs join (') join =
( Testing variant "array array") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array literal") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; /one_to_one Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array dict") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; << /rule /one_to_one >> Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array empty_dict") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; << >> Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array literal literal") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; /one_to_one /stdp_synapse Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array dict literal") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; << /rule /one_to_one >> /stdp_synapse Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array empty_dict literal") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; << >> /stdp_synapse Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array literal dict") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; /one_to_one << /model /stdp_synapse >> Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array literal empty_dict") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; /one_to_one << >> Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array dict dict") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; << /rule /one_to_one >> << /model /stdp_synapse >> Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array empty_dict dict") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; << >> << /model /stdp_synapse >> Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array dict empty_dict") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; << /rule /one_to_one >> << >> Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
( Testing variant "array array empty_dict empty_dict") =
ResetKernel
/iaf_neuron 6 Create ;
addresses arrayload ; << >> << >> Connect
<< /source [1 2 3] >> GetConnections dup
First /target get 4 eq assert_or_die
Last /target get 6 eq assert_or_die
} forall
(Running Connect tests with illegal combinations) =
ResetKernel
/n_connections 0 def
modeldict
{
pop % remove model id
/model_a Set
/type_a model_a GetDefaults /element_type get def
/m_a model_a Create def
modeldict
{
pop % remove model id
/model_b Set
/type_b model_b GetDefaults /element_type get def
/m_b model_b Create def
% try to connect model_a and model_b
{
m_a m_b Connect
} stopped not
{ % if there is no error, check that a connection has been made
{
n_connections 1 add
0 GetStatus /num_connections get
eq
} assert_or_die
/n_connections n_connections 1 add def
}
{
5 npop
} ifelse
} forall
} forall
(All illegal connections throw an error) =