|
| 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