Skip to content

Commit cfaef70

Browse files
authored
Merge pull request #3639 from heplesser/test_multiplicity
Port mpitests/test_multiplicity from SLI to Py
2 parents 6e0cead + eb57383 commit cfaef70

File tree

3 files changed

+57
-83
lines changed

3 files changed

+57
-83
lines changed

testsuite/mpitests/test_multiplicity.sli

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../test_multiplicity.py
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# test_multiplicity.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+
import numpy as np
23+
import pytest
24+
25+
26+
@pytest.mark.skipif_missing_threads
27+
def test_multiplicity():
28+
"""
29+
Confirm that spike multiplicity is handled correctly.
30+
31+
Creates two parrot neurons and connects the first one to the second one. The
32+
first parrot neuron receives one spike with multiplicity two from a spike
33+
generator, which should be communicated as two spikes to the second parrot
34+
neuron. Each parrot neuron is connected to a spike recorder, which should
35+
record two spikes.
36+
"""
37+
38+
import nest
39+
40+
nest.total_num_virtual_procs = 2
41+
42+
sg = nest.Create("spike_generator", params={"spike_times": [1.0], "spike_multiplicities": [2]})
43+
p_source, p_target = nest.Create("parrot_neuron", 2)
44+
sr_source, sr_target = nest.Create("spike_recorder", 2)
45+
46+
nest.Connect(sg, p_source)
47+
nest.Connect(p_source, p_target)
48+
nest.Connect(p_source, sr_source)
49+
nest.Connect(p_target, sr_target)
50+
51+
nest.Simulate(10)
52+
53+
# When running this on two MPI ranks, we need to make sure we check for spike times
54+
# only on the rank responsible for the neuron recorded by the recorder.
55+
assert not p_source.local or np.array_equal(sr_source.events["times"], [2, 2])
56+
assert not p_target.local or np.array_equal(sr_target.events["times"], [3, 3])

0 commit comments

Comments
 (0)