Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port test_steppedsim.sli to Pytest #2962

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions testsuite/pytests/sli2py_other/test_stepped_simulation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
#
# test_stepped_simulation.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 that multiple calls to ``Simulate`` give the same result as a single one.
"""

import nest


def build_net():
nest.ResetKernel()

nrn = nest.Create("iaf_psc_delta_ps")
sgen = nest.Create("spike_generator", params={"spike_times": [0.4], "precise_times": False})
srec = nest.Create("spike_recorder")

nest.Connect(sgen, nrn, syn_spec={"weight": 15.0, "delay": 1.0})
nest.Connect(nrn, srec)

return srec


def test_stepped_simulation():
"""Ensure that stepped simulation results in the same as a single."""

# Single simulation
srec_single = build_net()
nest.Simulate(3.0)
spikes_single = srec_single.events["times"]

# Stepped simulation
srec_stepped = build_net()
for _ in range(3):
nest.Simulate(1.0)
spikes_stepped = srec_stepped.events["times"]
heplesser marked this conversation as resolved.
Show resolved Hide resolved

# Stepped simulation with RunManager
srec_stepped_rm = build_net()
with nest.RunManager():
for _ in range(3):
nest.Run(1.0)
spikes_stepped_rm = srec_stepped_rm.events["times"]

# Compare
assert spikes_single == spikes_stepped
heplesser marked this conversation as resolved.
Show resolved Hide resolved
assert spikes_single == spikes_stepped_rm
74 changes: 0 additions & 74 deletions testsuite/unittests/test_steppedsim.sli

This file was deleted.

Loading