Skip to content

Commit e076ea5

Browse files
authored
Merge pull request #3382 from heplesser/sli2py_count_connections
Port test_count_connections from SLI to Py
2 parents a6892e0 + 220edc2 commit e076ea5

File tree

2 files changed

+65
-71
lines changed

2 files changed

+65
-71
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# test_count_connections.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+
pytestmark = pytest.mark.skipif_missing_threads
26+
27+
28+
@pytest.fixture(autouse=True)
29+
def prepare():
30+
nest.ResetKernel()
31+
32+
33+
def test_count_connections():
34+
"""
35+
Test that correct number of connections is created for fixed_indegree.
36+
37+
Description:
38+
This test uses fixed-indegree Connect to connect a net of 100 neurons
39+
to itself, with 89 connections per neuron, a total of 8900 connections.
40+
It is checked whether the total number of connections and the number of
41+
static connections equals 8900. Then additional 8900 connections of type
42+
stdp_synapse are created. It is checked whether the total number of
43+
connections is 17800 and the number of stdp connections is 8900.
44+
45+
Author: Susanne Kunkel, 2013-03-25
46+
"""
47+
48+
num_neurons = 100
49+
indegree = 89
50+
n_vp = 4
51+
expected_num_conns = num_neurons * indegree
52+
53+
nest.total_num_virtual_procs = 4
54+
55+
n = nest.Create("parrot_neuron", n=num_neurons)
56+
nest.Connect(n, n, conn_spec={"rule": "fixed_indegree", "indegree": indegree}, syn_spec="static_synapse")
57+
58+
assert nest.num_connections == expected_num_conns
59+
assert nest.GetDefaults("static_synapse")["num_connections"] == expected_num_conns
60+
61+
nest.Connect(n, n, conn_spec={"rule": "fixed_indegree", "indegree": indegree}, syn_spec="stdp_synapse")
62+
63+
assert nest.num_connections == 2 * expected_num_conns
64+
assert nest.GetDefaults("static_synapse")["num_connections"] == expected_num_conns
65+
assert nest.GetDefaults("stdp_synapse")["num_connections"] == expected_num_conns

testsuite/unittests/test_count_connections.sli

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)