1/* 2 * issue-665.sli 3 * 4 * This file is part of NEST. 5 * 6 * Copyright (C) 2004 The NEST Initiative 7 * 8 * NEST is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * NEST is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with NEST. If not, see <http://www.gnu.org/licenses/>. 20 * 21 */ 22 23 24 /** @BeginDocumentation 25Name: testsuite::issue-665 26 27Synopsis: (issue-665) run -> NEST exits if test fails 28 29Description: 30This test ensures that ConnectLayers correctly handles devices with thread 31siblings as sources and targets. 32 33Author: Hans Ekkehard Plesser 34FirstVersion: February 2017 35SeeAlso: 36*/ 37 38(unittest) run 39/unittest using 40 41skip_if_not_threaded 42 43% First set of tests: Single generator to neuron layer 44/gen_to_layer_test 45{ 46 /connspec Set 47 48 ResetKernel 49 << /local_num_threads 4 >> SetKernelStatus 50 51 /pgl 52 << /elements /poisson_generator 53 /shape [ 1 1 ] >> 54 CreateLayer def 55 56 /nnl 57 << /elements /iaf_psc_alpha 58 /shape [ 2 2 ] >> 59 CreateLayer def 60 61 pgl nnl connspec ConnectLayers 62 63 /src pgl [1] Take def 64 /tgts nnl def 65 66 /conns << /source src >> GetConnections def 67 /ctgts conns { cva 1 get } Map Sort def 68 69 tgts cva ctgts eq 70} 71def 72 73{ 74 << /connection_type /pairwise_bernoulli_on_source >> gen_to_layer_test 75} 76assert_or_die 77 78{ 79 << /connection_type /pairwise_bernoulli_on_target >> gen_to_layer_test 80} 81assert_or_die 82 83{ 84 % one incoming connection to each neuron in layer 85 << /connection_type /pairwise_bernoulli_on_source 86 /number_of_connections 1 >> gen_to_layer_test 87} 88assert_or_die 89 90{ 91 % four outgoing connections, one to each neuron in layer 92 % prohibit multapses to ensure consistent result 93 << /connection_type /pairwise_bernoulli_on_target 94 /number_of_connections 4 95 /allow_multapses false >> gen_to_layer_test 96} 97assert_or_die 98 99% ----------------------------------------------- 100 101% Second set of tests: Neuron layer to single recorder 102/layer_to_det_test 103{ 104 /connspec Set 105 106 ResetKernel 107 << /local_num_threads 4 >> SetKernelStatus 108 109 /nnl 110 << /elements /iaf_psc_alpha 111 /shape [ 2 2 ] >> 112 CreateLayer def 113 114 /srl 115 << /elements /spike_recorder 116 /shape [ 1 1 ] >> 117 CreateLayer def 118 119 nnl srl connspec ConnectLayers 120 121 /tgt srl [1] Take def 122 /srcs nnl def 123 124 /conns << /target tgt >> GetConnections def 125 /csrcs conns { cva 0 get } Map Sort def 126 127 srcs cva csrcs eq 128} 129def 130 131{ 132 << /connection_type /pairwise_bernoulli_on_source >> layer_to_det_test 133} 134assert_or_die 135 136{ 137 << /connection_type /pairwise_bernoulli_on_target >> layer_to_det_test 138} 139fail_or_die 140clear 141 142{ 143 % four incoming connections, one to each neuron in layer 144 % prohibit multapses to ensure consistent result 145 << /connection_type /pairwise_bernoulli_on_source 146 /number_of_connections 4 147 /allow_multapses false >> layer_to_det_test 148} 149fail_or_die 150clear 151 152{ 153 % one outgoing connection from each neuron in layer 154 << /connection_type /pairwise_bernoulli_on_target 155 /number_of_connections 1 >> layer_to_det_test 156} 157fail_or_die 158clear 159 160endusing 161