Skip to content

Commit 55b486b

Browse files
authored
Merge pull request #3457 from jessica-mitchell/sli2py_327
Port regression test 327 to Pytests
2 parents 66cb23b + eab802d commit 55b486b

File tree

2 files changed

+62
-85
lines changed

2 files changed

+62
-85
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# test_issue_327.py
4+
#
5+
# This file is part of NEST.
6+
#
7+
# Copyright (C) 2004 The NEST Initiative
8+
#
9+
# NEST is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation, either version 2 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# NEST is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
21+
"""
22+
Regression test for Issue #327 (GitHub).
23+
24+
This test ensures that NEST handles round-off correctly for large, precise spike times.
25+
"""
26+
27+
import nest
28+
import pytest
29+
30+
31+
def test_spike_generator_large_precise_times():
32+
"""
33+
Test that spike_generator handles large precise times correctly.
34+
"""
35+
nest.ResetKernel()
36+
nest.SetKernelStatus({"resolution": 0.1})
37+
38+
sg = nest.Create(
39+
"spike_generator",
40+
params={
41+
"precise_times": True,
42+
"spike_times": [353538.4 - 0.1], # Adjust for use of parrot_neuron by subtracting min_delay
43+
},
44+
)
45+
46+
pn = nest.Create("parrot_neuron_ps")
47+
sr = nest.Create("spike_recorder", params={"time_in_steps": True})
48+
49+
nest.Connect(sg, pn)
50+
nest.Connect(pn, sr)
51+
52+
nest.Simulate(360000)
53+
54+
events = nest.GetStatus(sr, "events")[0]
55+
times = events["times"]
56+
offsets = events["offsets"]
57+
58+
# Check correct step, account for delay 1 ms
59+
assert times[0] == 3535393
60+
61+
# Check for correct offset, precision limited by spike time * eps
62+
assert abs(offsets[0]) < 1e-9

testsuite/regressiontests/issue-327.sli

-85
This file was deleted.

0 commit comments

Comments
 (0)