|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# test_ticket_772.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 nest |
| 23 | +import pytest |
| 24 | + |
| 25 | + |
| 26 | +def test_integer_weights_and_delays_do_not_crash(): |
| 27 | + """ |
| 28 | + Regression test for Ticket #772. |
| 29 | +
|
| 30 | + Ensure that integer values for weight and delay do not crash NEST in Connect. |
| 31 | + """ |
| 32 | + # First test: single integer weight and delay |
| 33 | + nest.ResetKernel() |
| 34 | + n = nest.Create("iaf_psc_alpha", 2) |
| 35 | + nest.Connect( |
| 36 | + n, n, conn_spec={"rule": "all_to_all"}, syn_spec={"synapse_model": "static_synapse", "weight": 1, "delay": 4} |
| 37 | + ) |
| 38 | + |
| 39 | + # Second test: list of integer weights and delays (all_to_all) |
| 40 | + nest.ResetKernel() |
| 41 | + n = nest.Create("iaf_psc_alpha", 2) |
| 42 | + nest.Connect( |
| 43 | + n, |
| 44 | + n, |
| 45 | + conn_spec={"rule": "all_to_all"}, |
| 46 | + syn_spec={"synapse_model": "static_synapse", "weight": [1, 1], "delay": [4, 6]}, |
| 47 | + ) |
| 48 | + |
| 49 | + # Third test: list of integer weights and delays (one_to_one) |
| 50 | + nest.ResetKernel() |
| 51 | + n = nest.Create("iaf_psc_alpha", 2) |
| 52 | + nest.Connect( |
| 53 | + n, |
| 54 | + n, |
| 55 | + conn_spec={"rule": "one_to_one"}, |
| 56 | + syn_spec={"synapse_model": "static_synapse", "weight": [1, 1], "delay": [4, 6]}, |
| 57 | + ) |
| 58 | + # No assertion needed, test passes if no error is raised. |
0 commit comments