|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# test_issue_735.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 | +@pytest.mark.parametrize("use_param_on_connect", [True, False]) |
| 27 | +@pytest.mark.parametrize("copy_model", [True, False]) |
| 28 | +@pytest.mark.parametrize("param_name", ["A_minus", "A_plus", "Wmax", "Wmin", "b", "tau_c", "tau_n", "tau_plus"]) |
| 29 | +def test_issue_735(use_param_on_connect, copy_model, param_name): |
| 30 | + """ |
| 31 | + Regression test for Issue #735 (GitHub). |
| 32 | +
|
| 33 | + This test ensures that NEST raises an error if the user tries to set stdp parameters |
| 34 | + in ways that are not supported for stdp_dopamine_synapse. |
| 35 | + """ |
| 36 | + |
| 37 | + nest.ResetKernel() |
| 38 | + |
| 39 | + n = nest.Create("iaf_psc_alpha") |
| 40 | + vt = nest.Create("volume_transmitter") |
| 41 | + |
| 42 | + if copy_model: |
| 43 | + nest.CopyModel("stdp_dopamine_synapse", "mysyn", {"volume_transmitter": vt}) |
| 44 | + syn_model = "mysyn" |
| 45 | + else: |
| 46 | + nest.SetDefaults("stdp_dopamine_synapse", {"volume_transmitter": vt}) |
| 47 | + syn_model = "stdp_dopamine_synapse" |
| 48 | + |
| 49 | + if use_param_on_connect: |
| 50 | + with pytest.raises(nest.kernel.NESTErrors.NotImplemented): |
| 51 | + nest.Connect( |
| 52 | + n, |
| 53 | + n, |
| 54 | + conn_spec={"rule": "one_to_one"}, |
| 55 | + syn_spec={"synapse_model": syn_model, "weight": 2.0, param_name: 1.0}, |
| 56 | + ) |
| 57 | + else: |
| 58 | + nest.Connect(n, n, syn_spec={"synapse_model": syn_model, "weight": 2.0}) |
| 59 | + conns = nest.GetConnections() |
| 60 | + with pytest.raises(nest.kernel.NESTErrors.DictError): |
| 61 | + conns.set({param_name: 1.0, "weight": 2.0}) |
0 commit comments