|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# test_ticket_516.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 pytest |
| 23 | +from mpi_test_wrapper import MPITestAssertEqual |
| 24 | + |
| 25 | + |
| 26 | +@pytest.mark.skipif_incompatible_mpi |
| 27 | +@pytest.mark.parametrize("on_source", [True, False]) |
| 28 | +@MPITestAssertEqual([1, 2, 4], debug=False) |
| 29 | +def test_ticket_516(on_source): |
| 30 | + """ |
| 31 | + Confirm that simulations of a spatial network yield consistent spike trains. |
| 32 | +
|
| 33 | + The test compares data written by spike_recorder to SPIKE_LABEL. |
| 34 | + """ |
| 35 | + |
| 36 | + import nest |
| 37 | + |
| 38 | + nest.rng_seed = 1234567 |
| 39 | + nest.total_num_virtual_procs = 4 |
| 40 | + |
| 41 | + # Drive network with DC current, random connectivity and weights |
| 42 | + # lead to variation in spike times between neurons |
| 43 | + layer = nest.Create("iaf_psc_exp", params={"I_e": 500}, positions=nest.spatial.grid(shape=[5, 5], edge_wrap=False)) |
| 44 | + sr = nest.Create( |
| 45 | + "spike_recorder", |
| 46 | + params={ |
| 47 | + "record_to": "ascii", |
| 48 | + "time_in_steps": True, |
| 49 | + "label": SPIKE_LABEL.format(nest.num_processes), # noqa: F821 |
| 50 | + }, |
| 51 | + ) |
| 52 | + |
| 53 | + nest.Connect( |
| 54 | + layer, |
| 55 | + layer, |
| 56 | + {"rule": "pairwise_bernoulli", "use_on_source": on_source, "mask": {"circular": {"radius": 0.5}}, "p": 0.7}, |
| 57 | + {"weight": nest.random.uniform(-5, 15), "delay": 1}, |
| 58 | + ) |
| 59 | + |
| 60 | + nest.Connect(layer, sr) |
| 61 | + |
| 62 | + nest.Simulate(200) |
0 commit comments