-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2777 from nicolossus/port_test_multiple_random_so…
…urce_stepping Port `test_multiple_random_source_stepping` from SLI-2-Py
- Loading branch information
Showing
2 changed files
with
70 additions
and
89 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
testsuite/pytests/sli2py_other/test_multiple_random_source_stepping.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# test_multiple_random_source_stepping.py | ||
# | ||
# 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/>. | ||
|
||
""" | ||
Test NEST's behavior when using multiple random sources and different stepping schemes. | ||
The test checks whether simulations of a network with more than one node | ||
consuming random numbers creates identical output under different stepping | ||
regimes, e.g., 1x10.0ms vs 100x0.1ms. | ||
.. note:: | ||
This test works well only if the stepping interval is a multiple of the | ||
minimal delay. Otherwise, random numbers will be fed to consumers in | ||
different orders, as nodes are updated for parts of minimal delay periods | ||
only. | ||
""" | ||
|
||
import numpy.testing as nptest | ||
|
||
import nest | ||
|
||
|
||
def run_sim(interval, steppings): | ||
"""Single simulation run.""" | ||
|
||
nest.ResetKernel() | ||
|
||
pg1 = nest.Create("poisson_generator_ps", {"rate": 1000.0}) | ||
pg2 = nest.Create("poisson_generator_ps", {"rate": 1000.0}) | ||
sr1 = nest.Create("spike_recorder") | ||
sr2 = nest.Create("spike_recorder") | ||
nest.Connect(pg1, sr1) | ||
nest.Connect(pg2, sr2) | ||
|
||
for _ in range(steppings): | ||
nest.Simulate(interval) | ||
|
||
st1 = sr1.events["times"] | ||
st2 = sr2.events["times"] | ||
|
||
return st1, st2 | ||
|
||
|
||
def test_multiple_random_source_stepping(): | ||
st1_ref, st2_ref = run_sim(10.0, 1) | ||
st1_run1, st2_run1 = run_sim(5.0, 2) | ||
st1_run2, st2_run2 = run_sim(1.0, 10) | ||
|
||
nptest.assert_array_equal(st1_run1, st1_ref) | ||
nptest.assert_array_equal(st2_run1, st2_ref) | ||
nptest.assert_array_equal(st1_run2, st1_ref) | ||
nptest.assert_array_equal(st2_run2, st2_ref) |
89 changes: 0 additions & 89 deletions
89
testsuite/unittests/test_multiple_random_source_stepping.sli
This file was deleted.
Oops, something went wrong.