1/* 2 * test_spin_detector.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/** @BeginDocumentation 24 Name: testsuite::test_spin_detector - test decoding mechanism of binary events by spin_detector 25 26 Synopsis: (test_spin_detector) run -> test decoding mechanism of binary events by spin_detector 27 28 Description: 29 Test, whether the communication mechanism for binary neurons 30 works and whether the spin detector correctly decodes binary transitions. 31 Finally, setting the precision is tested. 32 33 FirstVersion: March 2013 34 Author: Mortiz Helias, Sepehr Mahmoudian 35*/ 36 37(unittest) run 38/unittest using 39 40 41/run_test 42{ 43 44 0.1 /h Set 45 46 ResetKernel 47 48 << 49 /local_num_threads 1 50 /resolution h 51 >> SetKernelStatus 52 53 % check, if double spikes are correctly interpreted as up transition 54 % and single spikes are interpreted as down transition 55 56 /sp /spin_detector Create def 57 58 /sg /spike_generator Create def 59 60 61 sg << /spike_times [10. 10. 15.] >> SetStatus 62 63 sg sp 1. 1. Connect 64 65 20. Simulate 66 67 % check if right state is decoded 68 69 sp /events get /state get /s Set 70 s 0 get 1 eq assert_or_die 71 s 1 get 0 eq assert_or_die 72 73 % check if recorded at the right times 74 sp /events get /times get /times Set 75 times cva 76 [ 10. 15.] eq 77 assert_or_die 78 79} def 80 81run_test 82