|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# test_voltmeter_reset.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_voltmeter_reset(): |
| 27 | + """ |
| 28 | + Test if resetting works on voltmeter. |
| 29 | +
|
| 30 | + The voltmeter records from iaf_psc_alpha to memory, checks if the proper number |
| 31 | + of data points is acquired, deleted on reset, and recorded again on further |
| 32 | + simulation. This test ascertains that also data stored in the derived recorder |
| 33 | + class, not only in RecordingDevice, is reset. |
| 34 | + """ |
| 35 | + |
| 36 | + nest.ResetKernel() |
| 37 | + |
| 38 | + n = nest.Create("iaf_psc_alpha") |
| 39 | + vm = nest.Create("voltmeter") |
| 40 | + vm.set({"interval": 1.0}) |
| 41 | + |
| 42 | + nest.Connect(vm, n) |
| 43 | + |
| 44 | + # Simulate and check initial recording |
| 45 | + nest.Simulate(10.5) |
| 46 | + events = vm.events |
| 47 | + assert vm.n_events == 10 |
| 48 | + assert len(events["times"]) == 10 |
| 49 | + assert len(events["V_m"]) == 10 |
| 50 | + |
| 51 | + # Reset voltmeter and check |
| 52 | + vm.set({"n_events": 0}) |
| 53 | + events = vm.events |
| 54 | + assert vm.n_events == 0 |
| 55 | + assert len(events["times"]) == 0 |
| 56 | + assert len(events["V_m"]) == 0 |
| 57 | + |
| 58 | + # Simulate more and check recording |
| 59 | + nest.Simulate(5.0) |
| 60 | + events = vm.events |
| 61 | + assert vm.n_events == 5 |
| 62 | + assert len(events["times"]) == 5 |
| 63 | + assert len(events["V_m"]) == 5 |
0 commit comments