|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# test_ticket_310.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 | +import nest |
| 23 | +import pytest |
| 24 | + |
| 25 | + |
| 26 | +def test_ticket_310(): |
| 27 | + """ |
| 28 | + Regression test for Ticket #310. |
| 29 | +
|
| 30 | + Ensure that all neuron models that have V_m and V_th permit |
| 31 | + V_m to be set to >= V_th, and that they emit a spike with |
| 32 | + time stamp == resolution in that case. |
| 33 | +
|
| 34 | + Author: Hans Ekkehard Plesser, 2009-02-11 |
| 35 | + """ |
| 36 | + |
| 37 | + # Use power-of-two resolution to avoid round-off problems |
| 38 | + res = 2**-3 |
| 39 | + |
| 40 | + skip_list = [ |
| 41 | + "iaf_chxk_2008", # non-standard spiking conditions |
| 42 | + "correlospinmatrix_detector", # not a neuron |
| 43 | + "eprop_iaf_bsshslm_2020", # no ArchivingNode, thus no t_spike |
| 44 | + "eprop_iaf_adapt_bsshslm_2020", # no ArchivingNode, thus no t_spike |
| 45 | + "eprop_readout_bsshslm_2020", # no ArchivingNode, thus no t_spike |
| 46 | + "eprop_iaf", # no ArchivingNode, thus no t_spike |
| 47 | + "eprop_iaf_adapt", # no ArchivingNode, thus no t_spike |
| 48 | + "eprop_iaf_psc_delta", # no ArchivingNode, thus no t_spike |
| 49 | + "eprop_iaf_psc_delta_adapt", # no ArchivingNode, thus no t_spike |
| 50 | + "eprop_readout", # no ArchivingNode, thus no t_spike |
| 51 | + ] |
| 52 | + |
| 53 | + node_models = nest.node_models |
| 54 | + |
| 55 | + results = [] |
| 56 | + |
| 57 | + for model in node_models: |
| 58 | + if model not in skip_list: |
| 59 | + nest.ResetKernel() |
| 60 | + nest.SetKernelStatus({"resolution": res}) |
| 61 | + n = nest.Create(model) |
| 62 | + |
| 63 | + # Check if V_m and V_th exist in the model's status |
| 64 | + status = nest.GetStatus(n)[0] |
| 65 | + if "V_m" in status and "V_th" in status: |
| 66 | + nest.SetStatus(n, {"V_m": status["V_th"] + 15.0}) |
| 67 | + nest.Simulate(res) |
| 68 | + t_spike = nest.GetStatus(n, "t_spike")[0] |
| 69 | + results.append(t_spike <= res) |
| 70 | + else: |
| 71 | + results.append(True) |
| 72 | + else: |
| 73 | + results.append(True) |
| 74 | + |
| 75 | + # Check if all entries are true |
| 76 | + assert all(results), "Test failed for one or more models" |
0 commit comments