Skip to content

Commit 7a86e0b

Browse files
committed
Nicely parameterize test
1 parent b54e0f0 commit 7a86e0b

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

testsuite/pytests/sli2py_regressions/test_ticket_310.py

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#
1414
# NEST is distributed in the hope that it will be useful,
1515
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
0 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717
# GNU General Public License for more details.
1818
#
1919
# You should have received a copy of the GNU General Public License
@@ -22,8 +22,32 @@
2222
import nest
2323
import pytest
2424

25+
# Models to skip to do given reasons
26+
skip_list = [
27+
"correlospinmatrix_detector", # not a neuron
28+
"eprop_iaf_bsshslm_2020", # no ArchivingNode, thus no t_spike
29+
"eprop_iaf_adapt_bsshslm_2020", # no ArchivingNode, thus no t_spike
30+
"eprop_readout_bsshslm_2020", # no ArchivingNode, thus no t_spike
31+
"eprop_iaf", # no ArchivingNode, thus no t_spike
32+
"eprop_iaf_adapt", # no ArchivingNode, thus no t_spike
33+
"eprop_iaf_psc_delta", # no ArchivingNode, thus no t_spike
34+
"eprop_iaf_psc_delta_adapt", # no ArchivingNode, thus no t_spike
35+
"eprop_readout", # no ArchivingNode, thus no t_spike
36+
"iaf_chxk_2008", # non-standard spiking conditions
37+
"izhikevich", # generating output spike not reliably suppressed even for subthreshold V_m
38+
]
2539

26-
def test_ticket_310():
40+
41+
def has_Vm_and_Vth(model):
42+
params = nest.GetDefaults(model)
43+
return "V_m" in params and "V_th" in params
44+
45+
46+
relevant_models = [model for model in nest.node_models if model not in skip_list and has_Vm_and_Vth(model)]
47+
48+
49+
@pytest.mark.parametrize("model", relevant_models)
50+
def test_ticket_310(model):
2751
"""
2852
Regression test for Ticket #310.
2953
@@ -34,43 +58,14 @@ def test_ticket_310():
3458
Author: Hans Ekkehard Plesser, 2009-02-11
3559
"""
3660

37-
# Use power-of-two resolution to avoid round-off problems
38-
res = 2**-3
39-
40-
skip_list = [
41-
"iaf_chxk_2008", # non-standard spiking conditions
42-
"correlospinmatrix_detector", # not a neuron
43-
"eprop_iaf_bsshslm_2020", # no ArchivingNode, thus no t_spike
44-
"eprop_iaf_adapt_bsshslm_2020", # no ArchivingNode, thus no t_spike
45-
"eprop_readout_bsshslm_2020", # no ArchivingNode, thus no t_spike
46-
"eprop_iaf", # no ArchivingNode, thus no t_spike
47-
"eprop_iaf_adapt", # no ArchivingNode, thus no t_spike
48-
"eprop_iaf_psc_delta", # no ArchivingNode, thus no t_spike
49-
"eprop_iaf_psc_delta_adapt", # no ArchivingNode, thus no t_spike
50-
"eprop_readout", # no ArchivingNode, thus no t_spike
51-
]
52-
53-
node_models = nest.node_models
61+
time_resolution = 2**-3 # Use power-of-two resolution to avoid round-off problems
5462

55-
results = []
63+
nest.ResetKernel()
64+
nest.resolution = time_resolution
5665

57-
for model in node_models:
58-
if model not in skip_list:
59-
nest.ResetKernel()
60-
nest.SetKernelStatus({"resolution": res})
61-
n = nest.Create(model)
66+
nrn = nest.Create(model)
67+
nrn.V_m = nrn.V_th + 15
6268

63-
# Check if V_m and V_th exist in the model's status
64-
status = nest.GetStatus(n)[0]
65-
if "V_m" in status and "V_th" in status:
66-
nest.SetStatus(n, {"V_m": status["V_th"] + 15.0})
67-
nest.Simulate(res)
68-
t_spike = nest.GetStatus(n, "t_spike")[0]
69-
results.append(t_spike <= res)
70-
else:
71-
results.append(True)
72-
else:
73-
results.append(True)
69+
nest.Simulate(time_resolution)
7470

75-
# Check if all entries are true
76-
assert all(results), "Test failed for one or more models"
71+
assert 0 < nrn.t_spike <= time_resolution # for precise neurons, < is possible; -1 if never spiked

0 commit comments

Comments
 (0)