Skip to content

Commit 1f4a80a

Browse files
authored
Merge pull request #3645 from heplesser/test_spatial_distributed_positions
Port test_spatial_distributed_positions from SLI to Py
2 parents a42365f + bbeb608 commit 1f4a80a

File tree

2 files changed

+50
-53
lines changed

2 files changed

+50
-53
lines changed

testsuite/mpitests/test_spatial_distributed_positions.sli

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# test_spatial_distributed_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+
@pytest.mark.skipif_incompatible_mpi
27+
@pytest.mark.skipif_missing_threads
28+
@MPITestAssertEqual([1, 2, 4], debug=False)
29+
def test_spatial_distributed_positions():
30+
"""
31+
Confirm that layers have metadata and that positions are consistent in parallel simulations.
32+
33+
The test is performed on connection data written to OTHER_LABEL.
34+
"""
35+
36+
import nest
37+
import pandas as pd
38+
39+
nest.total_num_virtual_procs = 4
40+
41+
layer = nest.Create(
42+
"parrot_neuron", positions=nest.spatial.free(pos=[(x, y) for x in range(3) for y in range(5)], edge_wrap=False)
43+
)
44+
meta = layer.spatial
45+
46+
assert meta is not None
47+
assert len(meta["positions"]) == sum(n.local for n in layer)
48+
49+
df = pd.DataFrame(meta["positions"])
50+
df.to_csv(OTHER_LABEL.format(nest.num_processes, nest.Rank()), index=False, sep="\t") # noqa: F821

0 commit comments

Comments
 (0)