/*
* test_set_Vm.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_set_Vm - test if setting V_m work via SetModelStatus and SetStatus
Synopsis: (test_set_Vm) run -> dies if assertion fails
Description:
This test goes through all models in modeldict for which V_m can be
set, and attempts to set V_m via SetModelStatus and SetStatus. It then
compares results. If both ways of setting V_m give different results,
something is wtong with state initialization.
Remarks:
The tests exploits that almost all neuron models have a state variable
V_m. It ignores all other models (the test returns true for them). The
new membrane potential that is set it the potential found in the
neuron +0.1mV. This should not conflict with any limitation requiring
the potential to be set to subthreshold values, but in pathological
cases it may lead to the exclusion of a model that should be tested.
Author: Plesser
FirstVersion: July 2008
*/
/unittest (7432) require
/unittest using
<< >> begin
/clear_error_push_true
{
counttomark npop % pop all but mark
errordict begin /newerror false def end /res true def
} def
{
modeldict keys
{
/model Set
/res false def
ResetKernel
mark
{
model GetDefaults /V_m get 0.1 add /newvm Set
}
stopped
{
clear_error_push_true % V_m unknown
}
{
{
% create neuron, set V_m on instance
model Create dup /dirsetnrn Set
<< /V_m newvm >> SetStatus
% set model status, then create instance
model << /V_m newvm >> SetDefaults
model Create /modsetnrn Set
} stopped
{
clear_error_push_true % V_m cannot be set
}
{
dirsetnrn [ /V_m ] get
modsetnrn [ /V_m ] get
eq /res Set
}
ifelse
}
ifelse
counttomark 1 add npop % pop mark
res
} Map
true exch { and } Fold
}
assert_or_die
end