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

Added protection against probabilistic wiring to spike_detector (fixes #351) #560

Merged
merged 5 commits into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ doc/normaldoc.conf
lib/sli/rcsinfo.sli
extras/emacs/sli.el
extras/nest_vars.sh
*.pyc

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this part of the pull request

7 changes: 7 additions & 0 deletions nestkernel/conn_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,13 @@ nest::ConnBuilder::single_connect_( index sgid,
thread target_thread,
librandom::RngPtr& rng )
{
if ( this->requires_proxies() and not target.has_proxies() )
{
throw IllegalConnection(
"Cannot use this rule to connect to nodes"
" without proxies (usually devices)." );
}

if ( param_dicts_.empty() ) // indicates we have no synapse params
{
if ( default_weight_and_delay_ )
Expand Down
19 changes: 19 additions & 0 deletions nestkernel/conn_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ class ConnBuilder
return false;
}

//! Return true if rule is applicable only to nodes with proxies
virtual bool
requires_proxies() const
{
return true;
}

protected:
//! Implements the actual connection algorithm
virtual void connect_() = 0;
Expand Down Expand Up @@ -248,6 +255,12 @@ class OneToOneBuilder : public ConnBuilder
return true;
}

bool
requires_proxies() const
{
return false;
}

protected:
void connect_();
void sp_connect_();
Expand All @@ -272,6 +285,12 @@ class AllToAllBuilder : public ConnBuilder
return *sources_ == *targets_ && all_parameters_scalar_();
}

bool
requires_proxies() const
{
return false;
}

protected:
void connect_();
void sp_connect_();
Expand Down
82 changes: 82 additions & 0 deletions testsuite/regressiontests/issue-351.sli
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* issue-351.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 <http://www.gnu.org/licenses/>.
*
*/

/* BeginDocumentation

Name: testsuite::issue-351 Ensure Connect raises exception if connecting to device with unusable rule

Synopsis: (issue-351) run -> NEST exits if test fails

Description:
This test makes sure that connections to devices without proxies are
prohibited for probabilistic connection rules.

Author: Hans Ekkehard Plesser, 2016-11-22
*/

(unittest) run
/unittest using

M_ERROR setverbosity

/prob_rules
[
<< /rule /fixed_indegree /indegree 1 >>
<< /rule /fixed_outdegree /outdegree 1 >>
<< /rule /fixed_total_number /N 1 >>
<< /rule /pairwise_bernoulli /p 1.0 >>
] def

/skip_list [ /multimeter /voltmeter % inverse order
/weight_recorder % attaches to synapses
/correlation_detector % has proxies
/correlomatrix_detector % has proxies
/spin_detector % binary recorders
/correlospinmatrix_detector
] def

modeldict keys
{
/model Set
model GetDefaults /element_type get /recorder eq
skip_list model MemberQ not and
{
prob_rules
{
/ruledict Set
(Testing ) =only model =only ( ) =only ruledict/rule :: =
{
ResetKernel
1 /iaf_psc_alpha Create cvgidcollection
2 model Create cvgidcollection
ruledict Connect
}
fail_or_die
clear
}
forall
}
if
}
forall

endusing