Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port issue-351.sli to Pytest #2816

Merged
merged 4 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions testsuite/pytests/sli2py_regressions/test_issue_351.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
#
# test_issue_351.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 <http://www.gnu.org/licenses/>.

"""
Regression test for Issue #351 (GitHub).

This test ensures `Connect` raises exception if connecting to recording device with probabilistic connection rule.
"""

import pytest

import nest


@pytest.fixture(autouse=True)
def reset():
nest.ResetKernel()


ignore_model = [
"multimeter", # inverse order
"voltmeter", # inverse order
"weight_recorder", # attaches to synapses
"correlation_detector", # has proxies
"correlomatrix_detector", # has proxies
"spin_detector", # binary recorder
"correlospinmatrix_detector", # binary recorder
]

models = [m for m in nest.node_models if nest.GetDefaults(m, "element_type") == "recorder" and m not in ignore_model]


@pytest.mark.parametrize("model", models)
@pytest.mark.parametrize(
"conn_spec",
[
{"rule": "fixed_indegree", "indegree": 1},
{"rule": "fixed_outdegree", "outdegree": 1},
{"rule": "fixed_total_number", "N": 1},
{"rule": "pairwise_bernoulli", "p": 1.0},
],
)
def test_error_raised_for_illegal_connections_to_recording_device(model, conn_spec):
"""
Test that an error is raised for prohibited connections to recording device.

This test ensures that connections to devices without proxies are prohibited
for probabilistic connection rules.
"""

nrn = nest.Create("iaf_psc_alpha", 1)
rec = nest.Create(model, 2)

with pytest.raises(nest.kernel.NESTErrors.IllegalConnection):
nest.Connect(nrn, rec, conn_spec=conn_spec)
82 changes: 0 additions & 82 deletions testsuite/regressiontests/issue-351.sli

This file was deleted.