/* * test_step_current_generator.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::test_step_current_generator - minimal test of noise_generator Synopsis: (test_step_current_generator) run -> dies if assertion fails Description: Tests parameter setting and statistical correctness for one application. Author: Plesser FirstVersion: July 2008 SeeAlso: noise_generator */ /unittest (7471) require /unittest using % First test: parameter setting on model and instance { ResetKernel /tdict << /amplitude_times [ 1.0 2.5 4.6 ] /amplitude_values [ 100.0 -100.0 200.0 ] >> def /ng1 /step_current_generator Create def ng1 tdict SetStatus /step_current_generator tdict SetDefaults /ng2 /step_current_generator Create def ng1 [tdict keys] get cva ng2 [tdict keys] get cva eq } assert_or_die clear ResetKernel % Second test: error if only times given { ResetKernel /step_current_generator << /amplitude_times [ 1.0 2.0 ] >> SetDefaults } fail_or_die % Third test: error if only values given { ResetKernel /step_current_generator << /amplitude_values [ 1.0 2.0 ] >> SetDefaults } fail_or_die % Fourth test: error if different sizes { ResetKernel /step_current_generator << /amplitude_values [ 1.0 2.0 ] /amplitude_times [ 1.0 2.0 3.0 ] >> SetDefaults } fail_or_die % Fifth test: error if times not strictly increasing { ResetKernel /step_current_generator << /amplitude_values [ 1.0 2.0 3.0 ] /amplitude_times [ 1.0 2.0 2.0 ] >> SetDefaults } fail_or_die % Sixth test: feed neuron and check response { ResetKernel 0 << /resolution 0.1 >> SetStatus /scg /step_current_generator Create def /nrn /iaf_neuron Create def /vm /voltmeter Create def % no spiking, all parameters 1, 0 leak potential nrn << /V_th 1e10 /C_m 1.0 /tau_m 1.0 /E_L 0.0 /V_reset 0.0 /V_m 0.0 >> SetStatus scg << /start 5.0 /stop 15.0 /amplitude_times [ 1.5 5.5 7.5 10.0 14.9 15.0 20.0 ] /amplitude_values [ 1. -2. 4. -8. 16. -32. 64. ] >> SetStatus vm << /record_to [/memory] /interval 0.1 >> SetStatus scg nrn Connect vm nrn Connect 25 Simulate /referenceSolution [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9.516260e-02 1.812690e-01 2.591820e-01 3.296800e-01 3.934690e-01 1.657010e-01 -4.039300e-02 -2.268740e-01 -3.956100e-01 -5.482870e-01 -6.864360e-01 -8.114380e-01 -9.245450e-01 -1.026890e+00 -1.119490e+00 -1.203280e+00 -1.279100e+00 -1.347700e+00 -1.409780e+00 -1.465940e+00 -1.516770e+00 -1.562750e+00 -1.604360e+00 -1.642010e+00 -1.676080e+00 -1.135930e+00 -6.471810e-01 -2.049430e-01 1.952100e-01 5.572840e-01 8.849020e-01 1.181340e+00 1.449570e+00 1.692280e+00 1.911890e+00 2.110600e+00 2.290400e+00 2.453090e+00 2.600300e+00 2.733500e+00 2.854020e+00 2.963070e+00 3.061750e+00 3.151040e+00 3.231830e+00 3.304930e+00 3.371070e+00 3.430920e+00 3.485080e+00 3.534080e+00 2.436470e+00 1.443310e+00 5.446560e-01 -2.684760e-01 -1.004230e+00 -1.669960e+00 -2.272350e+00 -2.817400e+00 -3.310590e+00 -3.756850e+00 -4.160640e+00 -4.526000e+00 -4.856600e+00 -5.155730e+00 -5.426400e+00 -5.671310e+00 -5.892910e+00 -6.093430e+00 -6.274860e+00 -6.439030e+00 -6.587580e+00 -6.721990e+00 -6.843610e+00 -6.953650e+00 -7.053230e+00 -7.143320e+00 -7.224850e+00 -7.298610e+00 -7.365360e+00 -7.425750e+00 -7.480400e+00 -7.529850e+00 -7.574590e+00 -7.615070e+00 -7.651700e+00 -7.684850e+00 -7.714840e+00 -7.741970e+00 -7.766530e+00 -7.788750e+00 -7.808850e+00 -7.827040e+00 -7.843500e+00 -7.858390e+00 -7.871870e+00 -7.884060e+00 -7.895090e+00 -7.905080e+00 -7.914110e+00 -5.638380e+00 -5.101820e+00 -4.616320e+00 -4.177020e+00 -3.779520e+00 -3.419850e+00 -3.094410e+00 -2.799940e+00 -2.533490e+00 -2.292400e+00 -2.074240e+00 -1.876850e+00 -1.698250e+00 -1.536640e+00 -1.390410e+00 -1.258090e+00 -1.138370e+00 -1.030040e+00 -9.320180e-01 -8.433250e-01 -7.630720e-01 -6.904560e-01 -6.247510e-01 -5.652980e-01 -5.115020e-01 -4.628270e-01 -4.187830e-01 -3.789300e-01 -3.428700e-01 -3.102420e-01 -2.807190e-01 -2.540050e-01 -2.298330e-01 -2.079610e-01 -1.881710e-01 -1.702640e-01 -1.540620e-01 -1.394010e-01 -1.261350e-01 -1.141320e-01 -1.032710e-01 -9.344310e-02 -8.455080e-02 -7.650470e-02 -6.922430e-02 -6.263680e-02 -5.667610e-02 -5.128260e-02 -4.640250e-02 -4.198670e-02 -3.799110e-02 -3.437580e-02 -3.110450e-02 -2.814450e-02 -2.546620e-02 -2.304280e-02 -2.085000e-02 -1.886580e-02 -1.707050e-02 -1.544600e-02 -1.397620e-02 -1.264610e-02 -1.144270e-02 -1.035380e-02 -9.368490e-03 -8.476960e-03 -7.670270e-03 -6.940350e-03 -6.279890e-03 -5.682280e-03 -5.141540e-03 -4.652260e-03 -4.209540e-03 -3.808950e-03 -3.446480e-03 -3.118500e-03 -2.821740e-03 -2.553210e-03 -2.310240e-03 -2.090390e-03 -1.891470e-03 ] def vm [ /events /V_m ] get cva 6 ToUnitTestPrecision referenceSolution eq } assert_or_die endusing