Skip to content

Commit 84da3b5

Browse files
authored
Merge pull request #3646 from heplesser/test_spatial_pwb_src_param
Port test_spatial_pairwise_bernoulli_on_source_param from SLI to Py
2 parents ebf603c + 37b94e9 commit 84da3b5

File tree

2 files changed

+57
-69
lines changed

2 files changed

+57
-69
lines changed

testsuite/mpitests/test_spatial_pairwise_bernoulli_on_source_param.sli

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# test_spatial_randomized_positions.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 pytest
23+
from mpi_test_wrapper import MPITestAssertEqual
24+
25+
"""
26+
Confirm that spatial positions are consistently generated from random parameters.
27+
"""
28+
29+
30+
@pytest.mark.skipif_incompatible_mpi
31+
@pytest.mark.skipif_missing_threads
32+
@MPITestAssertEqual([1, 2, 4], debug=False)
33+
def test_spatial_connections():
34+
"""
35+
Confirm that spatial positions are created consistently.
36+
37+
The test is performed on connection data written to OTHER_LABEL.
38+
"""
39+
40+
import nest
41+
import numpy as np
42+
import pandas as pd
43+
44+
nest.total_num_virtual_procs = 4
45+
46+
layer = nest.Create(
47+
"parrot_neuron",
48+
n=10,
49+
positions=nest.spatial.free([nest.random.uniform(0, 1), nest.random.uniform(2, 3), nest.random.uniform(4, 5)]),
50+
)
51+
pos = pd.DataFrame(layer.spatial["positions"], columns=["x", "y", "z"])
52+
53+
assert all((0 <= pos.x) & (pos.x <= 1))
54+
assert all((2 <= pos.y) & (pos.y <= 3))
55+
assert all((4 <= pos.z) & (pos.z <= 5))
56+
57+
pos.to_csv(OTHER_LABEL.format(nest.num_processes, nest.Rank()), index=False, sep="\t") # noqa: F821

0 commit comments

Comments
 (0)