|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# test_issue_2119.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 | +import pandas as pd |
| 24 | +import pytest |
| 25 | +from mpi_test_wrapper import MPITestAssertEqual |
| 26 | + |
| 27 | +# use default parameters for double-valued params |
| 28 | +random_params = [ |
| 29 | + ["'exponential'", {}], |
| 30 | + ["'normal'", {}], |
| 31 | + ["'lognormal'", {}], |
| 32 | + ["'uniform'", {}], |
| 33 | + ["'uniform_int'", {"max": 10}], |
| 34 | +] |
| 35 | + |
| 36 | + |
| 37 | +@pytest.mark.parametrize(["kind", "specs"], random_params) |
| 38 | +@MPITestAssertEqual([1, 2, 4]) |
| 39 | +def test_issue_2119(kind, specs): |
| 40 | + """ |
| 41 | + Confirm that randomized node parameters work correctly under MPI and OpenMP. |
| 42 | + """ |
| 43 | + |
| 44 | + import nest |
| 45 | + import pandas as pd |
| 46 | + |
| 47 | + nest.ResetKernel() |
| 48 | + nest.total_num_virtual_procs = 4 |
| 49 | + |
| 50 | + nrn = nest.Create("iaf_psc_alpha", n=4, params={"V_m": nest.CreateParameter(kind, specs)}) |
| 51 | + |
| 52 | + pd.DataFrame.from_dict(nrn.get(["global_id", "V_m"])).dropna().to_csv( |
| 53 | + OTHER_LABEL.format(nest.num_processes, nest.Rank()), index=False |
| 54 | + ) # noqa: F821 |
0 commit comments