From a7993f03ba2e0a353a1d6a61580a09b7981e1070 Mon Sep 17 00:00:00 2001 From: Jessica Mitchell Date: Tue, 22 Apr 2025 14:12:08 +0200 Subject: [PATCH] sli2py -mistral --- .../sli2py_regressions/test_issue_737.py | 79 ++++++++++++++++++ testsuite/regressiontests/issue-737.sli | 81 ------------------- 2 files changed, 79 insertions(+), 81 deletions(-) create mode 100644 testsuite/pytests/sli2py_regressions/test_issue_737.py delete mode 100644 testsuite/regressiontests/issue-737.sli diff --git a/testsuite/pytests/sli2py_regressions/test_issue_737.py b/testsuite/pytests/sli2py_regressions/test_issue_737.py new file mode 100644 index 0000000000..b23cd2edf8 --- /dev/null +++ b/testsuite/pytests/sli2py_regressions/test_issue_737.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +# +# test_issue_737.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 . +""" +Regression test for Issue #737 (GitHub). + +This test ensures that NEST raises an error if the user tries to set synapse +parameters that cannot be set with Connect calls. +""" + +import nest +import pytest + + +def test_static_synapse_hom_w_weight(): + """ + Test that setting weight in syn_spec for static_synapse_hom_w model raises an error. + """ + nest.ResetKernel() + n = nest.Create("iaf_psc_alpha") + + with pytest.raises(Exception): + nest.Connect( + n, n, conn_spec={"rule": "one_to_one"}, syn_spec={"synapse_model": "static_synapse_hom_w", "weight": 2.0} + ) + + +def test_copymodel_static_synapse_hom_w_weight(): + """ + Test that setting weight in syn_spec for CopyModel of static_synapse_hom_w model raises an error. + """ + nest.ResetKernel() + n = nest.Create("iaf_psc_alpha") + nest.CopyModel("static_synapse_hom_w", "mysyn") + + with pytest.raises(Exception): + nest.Connect(n, n, conn_spec={"rule": "one_to_one"}, syn_spec={"synapse_model": "mysyn", "weight": 2.0}) + + +def test_stdp_dopamine_synapse_vt(): + """ + Test that setting vt in syn_spec for stdp_dopamine_synapse model raises an error. + """ + nest.ResetKernel() + n = nest.Create("iaf_psc_alpha") + + with pytest.raises(Exception): + nest.Connect( + n, n, conn_spec={"rule": "one_to_one"}, syn_spec={"synapse_model": "stdp_dopamine_synapse", "vt": 2.0} + ) + + +def test_copymodel_stdp_dopamine_synapse_vt(): + """ + Test that setting vt in syn_spec for CopyModel of stdp_dopamine_synapse model raises an error. + """ + nest.ResetKernel() + n = nest.Create("iaf_psc_alpha") + nest.CopyModel("stdp_dopamine_synapse", "mysyn") + + with pytest.raises(Exception): + nest.Connect(n, n, conn_spec={"rule": "one_to_one"}, syn_spec={"synapse_model": "mysyn", "vt": 2.0}) diff --git a/testsuite/regressiontests/issue-737.sli b/testsuite/regressiontests/issue-737.sli deleted file mode 100644 index 76e91d2a15..0000000000 --- a/testsuite/regressiontests/issue-737.sli +++ /dev/null @@ -1,81 +0,0 @@ -/* - * issue-737.sli - * - * 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 . - * - */ - - - /** @BeginDocumentation -Name: testsuite::issue-737 - -Synopsis: (issue-737) run -> NEST exits if test fails - -Description: -This test ensures that NEST raises an error if the user tries to -set synapse parameters that cannot be set with Connect calls. - -Author: Stine B. Vennemo -FirstVersion: May 2017 -SeeAlso: testsuite::issue-735 -*/ - -(unittest) run -/unittest using - -M_ERROR setverbosity - -% Test weight in syn_spec for static_synapse_hom_w model -{ - ResetKernel - - /n /iaf_psc_alpha Create def - n n << /rule /one_to_one >> << /synapse_model /static_synapse_hom_w /weight 2.0 >> Connect - -} fail_or_die - -% Test weight in syn_spec for CopyModel of static_synapse_hom_w model -{ - ResetKernel - - /n /iaf_psc_alpha Create def - /static_synapse_hom_w /mysyn CopyModel - n n << /rule /one_to_one >> << /synapse_model /mysyn /weight 2.0 >> Connect - -} fail_or_die - -% Test vt in syn_spec for stdp_dopamine_synapse model -{ - ResetKernel - - /n /iaf_psc_alpha Create def - n n << /rule /one_to_one >> << /synapse_model /stdp_dopamine_synapse /vt 2.0 >> Connect - -} fail_or_die - -% Test vt in syn_spec for CopyModel of stdp_dopamine_synapse model -{ - ResetKernel - - /n /iaf_psc_alpha Create def - /stdp_dopamine_synapse /mysyn CopyModel - n n << /rule /one_to_one >> << /synapse_model /mysyn /vt 2.0 >> Connect - -} fail_or_die - -endusing