Skip to content

Commit c5e506c

Browse files
authored
Merge pull request #2627 from clinssen/set-Ca
Make calcium concentration available for setting
2 parents 228756c + 4bf97d8 commit c5e506c

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

nestkernel/structural_plasticity_node.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,19 @@ void
7676
nest::StructuralPlasticityNode::set_status( const DictionaryDatum& d )
7777
{
7878
// We need to preserve values in case invalid values are set
79+
double new_Ca_ = Ca_minus_;
7980
double new_tau_Ca = tau_Ca_;
8081
double new_beta_Ca = beta_Ca_;
82+
updateValue< double >( d, names::Ca, new_Ca_ );
8183
updateValue< double >( d, names::tau_Ca, new_tau_Ca );
8284
updateValue< double >( d, names::beta_Ca, new_beta_Ca );
8385

86+
if ( new_Ca_ < 0.0 )
87+
{
88+
throw BadProperty( "Calcium concentration cannot be negative." );
89+
}
90+
Ca_minus_ = new_Ca_;
91+
8492
if ( new_tau_Ca <= 0.0 )
8593
{
8694
throw BadProperty( "All time constants must be strictly positive." );

testsuite/pytests/test_calcium.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# test_calcium.py
4+
#
5+
# This file is part of NEST.
6+
#
7+
# Copyright (C) 2004 The NEST Initiative
8+
#
9+
# NEST is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation, either version 2 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# NEST is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
21+
22+
"""
23+
Test models with calcium concentration.
24+
This set of tests verify the behavior of the calcium concentration in models
25+
that inherit from the strutural plasticity node class in the kernel.
26+
"""
27+
28+
import nest
29+
import numpy as np
30+
import pytest
31+
32+
33+
@pytest.fixture(autouse=True)
34+
def reset_kernel():
35+
nest.ResetKernel()
36+
37+
38+
# Obtain all models with calcium concentration
39+
models = [model for model in nest.node_models if "Ca" in nest.GetDefaults(model)]
40+
41+
42+
def test_at_least_one_model():
43+
"""
44+
Verify that that at least one model contains calcium concentration.
45+
"""
46+
assert len(models) > 0
47+
48+
49+
@pytest.mark.parametrize("model", models)
50+
def test_calcium_set_get(model):
51+
"""
52+
Verify setters and getters for models with calcium concentration.
53+
"""
54+
55+
ca_default = nest.GetDefaults(model, "Ca")
56+
n = nest.Create(model, params={"Ca": ca_default + 42.0})
57+
np.testing.assert_allclose(n.Ca, ca_default + 42.)
58+
n.Ca = n.Ca + 99999.0
59+
np.testing.assert_allclose(n.Ca, ca_default + 42. + 99999.)

0 commit comments

Comments
 (0)