diff --git a/nestkernel/conn_builder.cpp b/nestkernel/conn_builder.cpp
index b802cdd869..b1b378865c 100644
--- a/nestkernel/conn_builder.cpp
+++ b/nestkernel/conn_builder.cpp
@@ -619,14 +619,14 @@ nest::OneToOneBuilder::connect_()
Node* target = n->get_node();
const size_t tnode_id = n->get_node_id();
- const int idx = targets_->find( tnode_id );
- if ( idx < 0 ) // Is local node in target list?
+ const long lid = targets_->get_lid( tnode_id );
+ if ( lid < 0 ) // Is local node in target list?
{
continue;
}
// one-to-one, thus we can use target idx for source as well
- const size_t snode_id = ( *sources_ )[ idx ];
+ const size_t snode_id = ( *sources_ )[ lid ];
if ( not allow_autapses_ and snode_id == tnode_id )
{
// no skipping required / possible,
@@ -819,7 +819,7 @@ nest::AllToAllBuilder::connect_()
const size_t tnode_id = n->get_node_id();
// Is the local node in the targets list?
- if ( targets_->find( tnode_id ) < 0 )
+ if ( targets_->get_lid( tnode_id ) < 0 )
{
continue;
}
@@ -1102,7 +1102,7 @@ nest::FixedInDegreeBuilder::connect_()
const size_t tnode_id = n->get_node_id();
// Is the local node in the targets list?
- if ( targets_->find( tnode_id ) < 0 )
+ if ( targets_->get_lid( tnode_id ) < 0 )
{
continue;
}
@@ -1534,7 +1534,7 @@ nest::BernoulliBuilder::connect_()
const size_t tnode_id = n->get_node_id();
// Is the local node in the targets list?
- if ( targets_->find( tnode_id ) < 0 )
+ if ( targets_->get_lid( tnode_id ) < 0 )
{
continue;
}
diff --git a/nestkernel/layer_impl.h b/nestkernel/layer_impl.h
index 4199ef2f35..5f44de8527 100644
--- a/nestkernel/layer_impl.h
+++ b/nestkernel/layer_impl.h
@@ -306,8 +306,9 @@ Layer< D >::dump_connections( std::ostream& out,
std::vector< std::pair< Position< D >, size_t > >* src_vec = get_global_positions_vector( node_collection );
// Dictionary with parameters for get_connections()
- DictionaryDatum ncdict( new Dictionary );
- def( ncdict, names::synapse_model, syn_model );
+ DictionaryDatum conn_filter( new Dictionary );
+ def( conn_filter, names::synapse_model, syn_model );
+ def( conn_filter, names::target, NodeCollectionDatum( target_layer->get_node_collection() ) );
// Avoid setting up new array for each iteration of the loop
std::vector< size_t > source_array( 1 );
@@ -321,8 +322,8 @@ Layer< D >::dump_connections( std::ostream& out,
const Position< D > source_pos = src_iter->first;
source_array[ 0 ] = source_node_id;
- def( ncdict, names::source, NodeCollectionDatum( NodeCollection::create( source_array ) ) );
- ArrayDatum connectome = kernel().connection_manager.get_connections( ncdict );
+ def( conn_filter, names::source, NodeCollectionDatum( NodeCollection::create( source_array ) ) );
+ ArrayDatum connectome = kernel().connection_manager.get_connections( conn_filter );
// Print information about all local connections for current source
for ( size_t i = 0; i < connectome.size(); ++i )
@@ -344,8 +345,9 @@ Layer< D >::dump_connections( std::ostream& out,
Layer< D >* tgt_layer = dynamic_cast< Layer< D >* >( target_layer.get() );
out << ' ';
- const size_t tnode_id = tgt_layer->node_collection_->find( target_node_id );
- tgt_layer->compute_displacement( source_pos, tnode_id ).print( out );
+ const long tnode_lid = tgt_layer->node_collection_->get_lid( target_node_id );
+ assert( tnode_lid >= 0 );
+ tgt_layer->compute_displacement( source_pos, tnode_lid ).print( out );
out << '\n';
}
}
diff --git a/nestkernel/nestmodule.cpp b/nestkernel/nestmodule.cpp
index 927790abc1..079f178430 100644
--- a/nestkernel/nestmodule.cpp
+++ b/nestkernel/nestmodule.cpp
@@ -1072,7 +1072,7 @@ NestModule::Find_g_iFunction::execute( SLIInterpreter* i ) const
NodeCollectionDatum nodecollection = getValue< NodeCollectionDatum >( i->OStack.pick( 1 ) );
const long node_id = getValue< long >( i->OStack.pick( 0 ) );
- const auto res = nodecollection->find( node_id );
+ const auto res = nodecollection->get_lid( node_id );
i->OStack.pop( 2 );
i->OStack.push( res );
i->EStack.pop();
diff --git a/nestkernel/node_collection.cpp b/nestkernel/node_collection.cpp
index 97be48d15c..e1ae755c4b 100644
--- a/nestkernel/node_collection.cpp
+++ b/nestkernel/node_collection.cpp
@@ -981,11 +981,11 @@ NodeCollectionComposite::merge_parts_( std::vector< NodeCollectionPrimitive >& p
bool
NodeCollectionComposite::contains( const size_t node_id ) const
{
- return find( node_id ) != -1;
+ return get_lid( node_id ) != -1;
}
long
-NodeCollectionComposite::find( const size_t node_id ) const
+NodeCollectionComposite::get_lid( const size_t node_id ) const
{
const auto add_size_op = []( const long a, const NodeCollectionPrimitive& b ) { return a + b.size(); };
@@ -1018,7 +1018,7 @@ NodeCollectionComposite::find( const size_t node_id ) const
// Need to find number of nodes in previous parts to know if the the step hits the node_id.
const auto num_prev_nodes =
std::accumulate( parts_.begin(), parts_.begin() + middle, static_cast< size_t >( 0 ), add_size_op );
- const auto absolute_pos = num_prev_nodes + parts_[ middle ].find( node_id );
+ const auto absolute_pos = num_prev_nodes + parts_[ middle ].get_lid( node_id );
// The first or the last node can be somewhere in the middle part.
const auto absolute_part_start = start_part_ == middle ? start_offset_ : 0;
@@ -1041,7 +1041,7 @@ NodeCollectionComposite::find( const size_t node_id ) const
// Since NC is not sliced, we can just calculate and return the local ID.
const auto sum_pre =
std::accumulate( parts_.begin(), parts_.begin() + middle, static_cast< size_t >( 0 ), add_size_op );
- return sum_pre + parts_[ middle ].find( node_id );
+ return sum_pre + parts_[ middle ].get_lid( node_id );
}
}
}
diff --git a/nestkernel/node_collection.h b/nestkernel/node_collection.h
index 0fc5e08334..27a9e4c514 100644
--- a/nestkernel/node_collection.h
+++ b/nestkernel/node_collection.h
@@ -386,7 +386,7 @@ class NodeCollection
*
* @return Index of node with given node ID; -1 if node not in NodeCollection.
*/
- virtual long find( const size_t ) const = 0;
+ virtual long get_lid( const size_t ) const = 0;
/**
* Returns whether the NodeCollection contains any nodes with proxies or not.
@@ -512,7 +512,7 @@ class NodeCollectionPrimitive : public NodeCollection
bool is_range() const override;
bool empty() const override;
- long find( const size_t ) const override;
+ long get_lid( const size_t ) const override;
bool has_proxies() const override;
@@ -650,7 +650,7 @@ class NodeCollectionComposite : public NodeCollection
bool is_range() const override;
bool empty() const override;
- long find( const size_t ) const override;
+ long get_lid( const size_t ) const override;
bool has_proxies() const override;
};
@@ -807,7 +807,7 @@ NodeCollectionPrimitive::empty() const
}
inline long
-NodeCollectionPrimitive::find( const size_t neuron_id ) const
+NodeCollectionPrimitive::get_lid( const size_t neuron_id ) const
{
if ( neuron_id > last_ )
{
diff --git a/pynest/nest/lib/hl_api_helper.py b/pynest/nest/lib/hl_api_helper.py
index 8b602fd30b..0dba569547 100644
--- a/pynest/nest/lib/hl_api_helper.py
+++ b/pynest/nest/lib/hl_api_helper.py
@@ -24,17 +24,16 @@
API of the PyNEST wrapper.
"""
-import warnings
-import json
import functools
-import textwrap
+import json
import os
import pydoc
-
+import textwrap
+import warnings
from string import Template
-from ..ll_api import sli_func, sps, sr, spp
from .. import pynestkernel as kernel
+from ..ll_api import sli_func, spp, sps, sr
__all__ = [
"broadcast",
@@ -52,6 +51,7 @@
"restructure_data",
"show_deprecation_warning",
"show_help_with_pager",
+ "stringify_path",
"SuppressedDeprecationWarning",
]
@@ -148,6 +148,31 @@ def new_func(*args, **kwargs):
return deprecated_decorator
+def stringify_path(filepath):
+ """
+ Convert path-like object to string form.
+
+ Attempt to convert path-like object to a string by coercing objects
+ supporting the fspath protocol to its ``__fspath__`` method. Anything that
+ is not path-like, which includes bytes and strings, is passed through
+ unchanged.
+
+ Parameters
+ ----------
+ filepath : object
+ Object representing file system path.
+
+ Returns
+ -------
+ filepath : str
+ Stringified filepath.
+ """
+
+ if isinstance(filepath, os.PathLike):
+ filepath = filepath.__fspath__() # should return str or bytes object
+ return filepath
+
+
def is_literal(obj):
"""Check whether obj is a "literal": a unicode string or SLI literal
diff --git a/pynest/nest/lib/hl_api_spatial.py b/pynest/nest/lib/hl_api_spatial.py
index 19bfe1c952..42cfbc654a 100644
--- a/pynest/nest/lib/hl_api_spatial.py
+++ b/pynest/nest/lib/hl_api_spatial.py
@@ -23,19 +23,20 @@
Functions relating to spatial properties of nodes
"""
+import os
import numpy as np
from ..ll_api import sli_func
-from .hl_api_helper import is_iterable
from .hl_api_connections import GetConnections
+from .hl_api_helper import is_iterable, stringify_path
from .hl_api_parallel_computing import NumProcesses, Rank
from .hl_api_types import NodeCollection
try:
import matplotlib as mpl
- import matplotlib.path as mpath
import matplotlib.patches as mpatches
+ import matplotlib.path as mpath
HAVE_MPL = True
except ImportError:
@@ -530,9 +531,12 @@ def DumpLayerNodes(layer, outname):
nest.DumpLayerNodes(s_nodes, 'positions.txt')
"""
+
if not isinstance(layer, NodeCollection):
raise TypeError("layer must be a NodeCollection")
+ outname = stringify_path(outname)
+
sli_func(
"""
(w) file exch DumpLayerNodes close
@@ -599,11 +603,15 @@ def DumpLayerConnections(source_layer, target_layer, synapse_model, outname):
# write connectivity information to file
nest.DumpLayerConnections(s_nodes, s_nodes, 'static_synapse', 'conns.txt')
"""
+
if not isinstance(source_layer, NodeCollection):
raise TypeError("source_layer must be a NodeCollection")
+
if not isinstance(target_layer, NodeCollection):
raise TypeError("target_layer must be a NodeCollection")
+ outname = stringify_path(outname)
+
sli_func(
"""
/oname Set
@@ -1467,8 +1475,8 @@ def _create_mask_patches(mask, periodic, extent, source_pos, face_color="yellow"
# import pyplot here and not at toplevel to avoid preventing users
# from changing matplotlib backend after importing nest
- import matplotlib.pyplot as plt
import matplotlib as mtpl
+ import matplotlib.pyplot as plt
edge_color = "black"
alpha = 0.2
diff --git a/testsuite/pytests/sli2py_regressions/test_issue_2629.py b/testsuite/pytests/sli2py_regressions/test_issue_2629.py
new file mode 100644
index 0000000000..270c6b66be
--- /dev/null
+++ b/testsuite/pytests/sli2py_regressions/test_issue_2629.py
@@ -0,0 +1,91 @@
+# -*- coding: utf-8 -*-
+#
+# test_issue_2629.py
+#
+# This file is part of NEST.
+#
+# Copyright (C) 2004 The NEST Initiative
+#
+# NEST is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# NEST is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NEST. If not, see .
+
+"""
+Regression test for Issue #2629 (GitHub).
+
+The issue was that ``DumpLayerConnections`` failed when a source layer was
+connected to more than one target layer. The test ensures that this is no
+longer the case.
+
+For each connection between the specified source and target layer,
+``DumpLayerConnections`` writes the following to file:
+
+ source_node_id target_node_id weight delay dx dy [dz]
+
+where (dx, dy [, dz]) is the displacement from source to target node.
+
+This test uses the ``tmp_path`` Pytest fixture, which will provide a
+temporary directory unique to the test invocation. ``tmp_path`` is a
+``pathlib.Path`` object. Hence, the test also implicitly verifies that it
+is possible to pass a ``pathlib.Path`` object as filename.
+"""
+
+import pytest
+
+import nest
+
+
+@pytest.fixture(scope="module")
+def network():
+ """Fixture for building network."""
+
+ grid = nest.spatial.grid(shape=[2, 1])
+ src_layer = nest.Create("iaf_psc_alpha", positions=grid)
+ tgt_layer_1 = nest.Create("iaf_psc_alpha", positions=grid)
+ tgt_layer_2 = nest.Create("iaf_psc_alpha", positions=grid)
+
+ nest.Connect(src_layer, tgt_layer_1, "all_to_all")
+ nest.Connect(src_layer, tgt_layer_2, "one_to_one")
+
+ return src_layer, tgt_layer_1, tgt_layer_2
+
+
+def test_dump_layer_connections_target_1(tmp_path, network):
+ """Test that dumping connections with target layer 1 works."""
+
+ src_layer, tgt_layer_1, _ = network
+
+ fname_1 = tmp_path / "conns_1.txt"
+ nest.DumpLayerConnections(src_layer, tgt_layer_1, "static_synapse", fname_1)
+ expected_dump_1 = [
+ "1 3 1 1 0 0",
+ "1 4 1 1 0.5 0",
+ "2 3 1 1 -0.5 0",
+ "2 4 1 1 0 0",
+ ]
+ actual_dump_1 = fname_1.read_text().splitlines()
+ assert actual_dump_1 == expected_dump_1
+
+
+def test_dump_layer_connections_target_2(tmp_path, network):
+ """Test that dumping connections with target layer 2 works."""
+
+ src_layer, _, tgt_layer_2 = network
+
+ fname_2 = tmp_path / "conns_2.txt"
+ nest.DumpLayerConnections(src_layer, tgt_layer_2, "static_synapse", fname_2)
+ expected_dump_2 = [
+ "1 5 1 1 0 0",
+ "2 6 1 1 0 0",
+ ]
+ actual_dump_2 = fname_2.read_text().splitlines()
+ assert actual_dump_2 == expected_dump_2
diff --git a/testsuite/pytests/test_spatial/test_weight_delay.py b/testsuite/pytests/test_spatial/test_weight_delay.py
new file mode 100644
index 0000000000..4b3980c577
--- /dev/null
+++ b/testsuite/pytests/test_spatial/test_weight_delay.py
@@ -0,0 +1,265 @@
+# -*- coding: utf-8 -*-
+#
+# test_weight_delay.py
+#
+# This file is part of NEST.
+#
+# Copyright (C) 2004 The NEST Initiative
+#
+# NEST is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# NEST is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NEST. If not, see .
+
+"""
+Test setting weights and delays to arbitrary values limited by resolution.
+
+The test checks that weights and delays in a spatial network can be set to
+arbitrary values within the limits set by resolution. The test creates a layer
+with a single row and uses linear functions for weights and delays. Expected
+delays with resolution 0.04 are 1.0 0.96 0.96 0.92 0.92 0.88 0.84 and expected
+weights are 1.0, 0.98, 0.96, 0.94, 0.92, 0.90, 0.88, 0.86, 0.84, 0.82.
+"""
+
+import numpy as np
+import pytest
+
+import nest
+
+
+def build_network(layer_type):
+ """Build spatial network with specified layer type."""
+
+ nest.ResetKernel()
+ nest.resolution = 0.04
+ nest.use_compressed_spikes = False
+ nest.sort_connections_by_source = False
+
+ p1 = nest.CreateParameter("constant", {"value": 1.0})
+ p2 = nest.CreateParameter("constant", {"value": -0.02})
+ p3 = nest.CreateParameter("distance", {})
+ linear_parameter = p1 + p2 * p3
+
+ syn_spec = {
+ "weight": linear_parameter,
+ "delay": linear_parameter,
+ }
+
+ if layer_type == "grid":
+ pos = nest.spatial.grid(
+ shape=[10, 1],
+ extent=[10.0, 1.0],
+ center=[0.0, 0.0],
+ edge_wrap=True,
+ )
+ conn_spec = {
+ "rule": "pairwise_bernoulli",
+ "use_on_source": False,
+ "mask": {"grid": {"shape": [10, 1]}, "anchor": [0, 0]},
+ }
+ elif layer_type == "free":
+ pos = nest.spatial.free(
+ [[x, 0.0] for x in np.linspace(-4.5, 4.5, 10)],
+ extent=[10.0, 1.0],
+ edge_wrap=True,
+ )
+ conn_spec = {
+ "rule": "pairwise_bernoulli",
+ "use_on_source": False,
+ "mask": {"rectangular": {"lower_left": [-0.5, -0.5], "upper_right": [9.5, 0.5]}},
+ }
+
+ src_layer = nest.Create("iaf_psc_alpha", positions=pos)
+ tgt_layer = nest.Create("iaf_psc_alpha", positions=pos)
+
+ nest.Connect(src_layer, tgt_layer, conn_spec=conn_spec, syn_spec=syn_spec)
+
+ return src_layer, tgt_layer
+
+
+@pytest.mark.parametrize("layer_type", ["grid", "free"])
+def test_source_layer_nodes_dump(tmp_path, expected_source_nodes_dump, layer_type):
+ """Test that source layer nodes dump mathces expectation."""
+
+ src_layer, _ = build_network(layer_type)
+
+ fname = tmp_path / f"{layer_type}_source_nodes.txt"
+ nest.DumpLayerNodes(src_layer, fname)
+
+ actual_source_nodes_dump = fname.read_text().splitlines()
+ assert actual_source_nodes_dump == expected_source_nodes_dump
+
+
+@pytest.mark.parametrize("layer_type", ["grid", "free"])
+def test_target_layer_nodes_dump(tmp_path, expected_target_nodes_dump, layer_type):
+ """Test that target layer nodes dump mathces expectation."""
+
+ _, tgt_layer = build_network(layer_type)
+
+ fname = tmp_path / f"{layer_type}_target_nodes.txt"
+ nest.DumpLayerNodes(tgt_layer, fname)
+
+ actual_target_nodes_dump = fname.read_text().splitlines()
+ assert actual_target_nodes_dump == expected_target_nodes_dump
+
+
+@pytest.mark.parametrize("layer_type", ["grid", "free"])
+def test_layer_connections_dump(tmp_path, expected_conn_dump, layer_type):
+ """Test that layer connections dump mathces expectation."""
+
+ src_layer, tgt_layer = build_network(layer_type)
+
+ fname = tmp_path / f"{layer_type}_layer_conns.txt"
+ nest.DumpLayerConnections(src_layer, tgt_layer, "static_synapse", fname)
+
+ actual_conn_dump = fname.read_text().splitlines()
+ assert actual_conn_dump == expected_conn_dump
+
+
+@pytest.fixture(scope="module")
+def expected_source_nodes_dump():
+ expected_source_nodes_dump = [
+ "1 -4.5 0",
+ "2 -3.5 0",
+ "3 -2.5 0",
+ "4 -1.5 0",
+ "5 -0.5 0",
+ "6 0.5 0",
+ "7 1.5 0",
+ "8 2.5 0",
+ "9 3.5 0",
+ "10 4.5 0",
+ ]
+ return expected_source_nodes_dump
+
+
+@pytest.fixture(scope="module")
+def expected_target_nodes_dump():
+ expected_target_nodes_dump = [
+ "11 -4.5 0",
+ "12 -3.5 0",
+ "13 -2.5 0",
+ "14 -1.5 0",
+ "15 -0.5 0",
+ "16 0.5 0",
+ "17 1.5 0",
+ "18 2.5 0",
+ "19 3.5 0",
+ "20 4.5 0",
+ ]
+ return expected_target_nodes_dump
+
+
+@pytest.fixture(scope="module")
+def expected_conn_dump():
+ expected_conn_dump = [
+ "1 11 1 1 0 0",
+ "1 12 0.98 1 1 0",
+ "1 13 0.96 0.96 2 0",
+ "1 14 0.94 0.96 3 0",
+ "1 15 0.92 0.92 4 0",
+ "1 16 0.9 0.92 -5 0",
+ "1 17 0.92 0.92 -4 0",
+ "1 18 0.94 0.96 -3 0",
+ "1 19 0.96 0.96 -2 0",
+ "1 20 0.98 1 -1 0",
+ "2 11 0.98 1 -1 0",
+ "2 12 1 1 0 0",
+ "2 13 0.98 1 1 0",
+ "2 14 0.96 0.96 2 0",
+ "2 15 0.94 0.96 3 0",
+ "2 16 0.92 0.92 4 0",
+ "2 17 0.9 0.92 -5 0",
+ "2 18 0.92 0.92 -4 0",
+ "2 19 0.94 0.96 -3 0",
+ "2 20 0.96 0.96 -2 0",
+ "3 11 0.96 0.96 -2 0",
+ "3 12 0.98 1 -1 0",
+ "3 13 1 1 0 0",
+ "3 14 0.98 1 1 0",
+ "3 15 0.96 0.96 2 0",
+ "3 16 0.94 0.96 3 0",
+ "3 17 0.92 0.92 4 0",
+ "3 18 0.9 0.92 -5 0",
+ "3 19 0.92 0.92 -4 0",
+ "3 20 0.94 0.96 -3 0",
+ "4 11 0.94 0.96 -3 0",
+ "4 12 0.96 0.96 -2 0",
+ "4 13 0.98 1 -1 0",
+ "4 14 1 1 0 0",
+ "4 15 0.98 1 1 0",
+ "4 16 0.96 0.96 2 0",
+ "4 17 0.94 0.96 3 0",
+ "4 18 0.92 0.92 4 0",
+ "4 19 0.9 0.92 -5 0",
+ "4 20 0.92 0.92 -4 0",
+ "5 11 0.92 0.92 -4 0",
+ "5 12 0.94 0.96 -3 0",
+ "5 13 0.96 0.96 -2 0",
+ "5 14 0.98 1 -1 0",
+ "5 15 1 1 0 0",
+ "5 16 0.98 1 1 0",
+ "5 17 0.96 0.96 2 0",
+ "5 18 0.94 0.96 3 0",
+ "5 19 0.92 0.92 4 0",
+ "5 20 0.9 0.92 -5 0",
+ "6 11 0.9 0.92 -5 0",
+ "6 12 0.92 0.92 -4 0",
+ "6 13 0.94 0.96 -3 0",
+ "6 14 0.96 0.96 -2 0",
+ "6 15 0.98 1 -1 0",
+ "6 16 1 1 0 0",
+ "6 17 0.98 1 1 0",
+ "6 18 0.96 0.96 2 0",
+ "6 19 0.94 0.96 3 0",
+ "6 20 0.92 0.92 4 0",
+ "7 11 0.92 0.92 4 0",
+ "7 12 0.9 0.92 -5 0",
+ "7 13 0.92 0.92 -4 0",
+ "7 14 0.94 0.96 -3 0",
+ "7 15 0.96 0.96 -2 0",
+ "7 16 0.98 1 -1 0",
+ "7 17 1 1 0 0",
+ "7 18 0.98 1 1 0",
+ "7 19 0.96 0.96 2 0",
+ "7 20 0.94 0.96 3 0",
+ "8 11 0.94 0.96 3 0",
+ "8 12 0.92 0.92 4 0",
+ "8 13 0.9 0.92 -5 0",
+ "8 14 0.92 0.92 -4 0",
+ "8 15 0.94 0.96 -3 0",
+ "8 16 0.96 0.96 -2 0",
+ "8 17 0.98 1 -1 0",
+ "8 18 1 1 0 0",
+ "8 19 0.98 1 1 0",
+ "8 20 0.96 0.96 2 0",
+ "9 11 0.96 0.96 2 0",
+ "9 12 0.94 0.96 3 0",
+ "9 13 0.92 0.92 4 0",
+ "9 14 0.9 0.92 -5 0",
+ "9 15 0.92 0.92 -4 0",
+ "9 16 0.94 0.96 -3 0",
+ "9 17 0.96 0.96 -2 0",
+ "9 18 0.98 1 -1 0",
+ "9 19 1 1 0 0",
+ "9 20 0.98 1 1 0",
+ "10 11 0.98 1 1 0",
+ "10 12 0.96 0.96 2 0",
+ "10 13 0.94 0.96 3 0",
+ "10 14 0.92 0.92 4 0",
+ "10 15 0.9 0.92 -5 0",
+ "10 16 0.92 0.92 -4 0",
+ "10 17 0.94 0.96 -3 0",
+ "10 18 0.96 0.96 -2 0",
+ "10 19 0.98 1 -1 0",
+ "10 20 1 1 0 0",
+ ]
+ return expected_conn_dump
diff --git a/testsuite/unittests/test_weight_delay.sli b/testsuite/unittests/test_weight_delay.sli
deleted file mode 100644
index 35083acdcd..0000000000
--- a/testsuite/unittests/test_weight_delay.sli
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * test_weight_delay.sli
- *
- * This file is part of NEST.
- *
- * Copyright (C) 2004 The NEST Initiative
- *
- * NEST is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * NEST is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with NEST. If not, see .
- *
- */
-
-
-% this tests checks if weights and delays can be set to
-% arbitrary values within the limits set by resolution
-%
-% It creates a grid with a single row and uses linear functions for weights and delays
-% Expected weights are 1., 0.98, 0.96, 0.94, 0.92, 0.90, 0.88, 0.86, 0.84, 0.82
-% Expected delays with resolution 0.04 are 1.0 0.96 0.96 0.92 0.92 0.88 0.84
-
-/layer << /shape [ 10 1 ]
- /extent [10. 1.]
- /center [0. 0.]
- /edge_wrap true
- /elements /iaf_psc_alpha
- >> def
-
-/src_layer layer def
-/tgt_layer layer def
-
-<< /constant << /value 1.0 >> >> CreateParameter
-<< /constant << /value -0.02 >> >> CreateParameter
-<< /distance << >> >> CreateParameter
-mul add /linear_parameter Set
-
-/conns << /connection_type (pairwise_bernoulli_on_target)
- /mask << /grid << /shape [ 10 1 ] >> /anchor [ 0 0 ] >>
- /weight linear_parameter
- /delay linear_parameter
- >> def
-
-% required to make sure that resolution goes into userdict
-userdict begin
- /resolution 0.04 def
-end
-
-/source_layer_ref
-[
- [1 -4.5 0]
- [2 -3.5 0]
- [3 -2.5 0]
- [4 -1.5 0]
- [5 -0.5 0]
- [6 0.5 0]
- [7 1.5 0]
- [8 2.5 0]
- [9 3.5 0]
- [10 4.5 0]
-]
-def
-
-/target_layer_ref
-[
- [11 -4.5 0]
- [12 -3.5 0]
- [13 -2.5 0]
- [14 -1.5 0]
- [15 -0.5 0]
- [16 0.5 0]
- [17 1.5 0]
- [18 2.5 0]
- [19 3.5 0]
- [20 4.5 0]
-]
-def
-
-/conn_ref
-[
- [1 11 1 1 0 0]
- [1 12 0.98 1 1 0]
- [1 13 0.96 0.96 2 0]
- [1 14 0.94 0.96 3 0]
- [1 15 0.92 0.92 4 0]
- [1 16 0.9 0.92 -5 0]
- [1 17 0.92 0.92 -4 0]
- [1 18 0.94 0.96 -3 0]
- [1 19 0.96 0.96 -2 0]
- [1 20 0.98 1 -1 0]
- [2 11 0.98 1 -1 0]
- [2 12 1 1 0 0]
- [2 13 0.98 1 1 0]
- [2 14 0.96 0.96 2 0]
- [2 15 0.94 0.96 3 0]
- [2 16 0.92 0.92 4 0]
- [2 17 0.9 0.92 -5 0]
- [2 18 0.92 0.92 -4 0]
- [2 19 0.94 0.96 -3 0]
- [2 20 0.96 0.96 -2 0]
- [3 11 0.96 0.96 -2 0]
- [3 12 0.98 1 -1 0]
- [3 13 1 1 0 0]
- [3 14 0.98 1 1 0]
- [3 15 0.96 0.96 2 0]
- [3 16 0.94 0.96 3 0]
- [3 17 0.92 0.92 4 0]
- [3 18 0.9 0.92 -5 0]
- [3 19 0.92 0.92 -4 0]
- [3 20 0.94 0.96 -3 0]
- [4 11 0.94 0.96 -3 0]
- [4 12 0.96 0.96 -2 0]
- [4 13 0.98 1 -1 0]
- [4 14 1 1 0 0]
- [4 15 0.98 1 1 0]
- [4 16 0.96 0.96 2 0]
- [4 17 0.94 0.96 3 0]
- [4 18 0.92 0.92 4 0]
- [4 19 0.9 0.92 -5 0]
- [4 20 0.92 0.92 -4 0]
- [5 11 0.92 0.92 -4 0]
- [5 12 0.94 0.96 -3 0]
- [5 13 0.96 0.96 -2 0]
- [5 14 0.98 1 -1 0]
- [5 15 1 1 0 0]
- [5 16 0.98 1 1 0]
- [5 17 0.96 0.96 2 0]
- [5 18 0.94 0.96 3 0]
- [5 19 0.92 0.92 4 0]
- [5 20 0.9 0.92 -5 0]
- [6 11 0.9 0.92 -5 0]
- [6 12 0.92 0.92 -4 0]
- [6 13 0.94 0.96 -3 0]
- [6 14 0.96 0.96 -2 0]
- [6 15 0.98 1 -1 0]
- [6 16 1 1 0 0]
- [6 17 0.98 1 1 0]
- [6 18 0.96 0.96 2 0]
- [6 19 0.94 0.96 3 0]
- [6 20 0.92 0.92 4 0]
- [7 11 0.92 0.92 4 0]
- [7 12 0.9 0.92 -5 0]
- [7 13 0.92 0.92 -4 0]
- [7 14 0.94 0.96 -3 0]
- [7 15 0.96 0.96 -2 0]
- [7 16 0.98 1 -1 0]
- [7 17 1 1 0 0]
- [7 18 0.98 1 1 0]
- [7 19 0.96 0.96 2 0]
- [7 20 0.94 0.96 3 0]
- [8 11 0.94 0.96 3 0]
- [8 12 0.92 0.92 4 0]
- [8 13 0.9 0.92 -5 0]
- [8 14 0.92 0.92 -4 0]
- [8 15 0.94 0.96 -3 0]
- [8 16 0.96 0.96 -2 0]
- [8 17 0.98 1 -1 0]
- [8 18 1 1 0 0]
- [8 19 0.98 1 1 0]
- [8 20 0.96 0.96 2 0]
- [9 11 0.96 0.96 2 0]
- [9 12 0.94 0.96 3 0]
- [9 13 0.92 0.92 4 0]
- [9 14 0.9 0.92 -5 0]
- [9 15 0.92 0.92 -4 0]
- [9 16 0.94 0.96 -3 0]
- [9 17 0.96 0.96 -2 0]
- [9 18 0.98 1 -1 0]
- [9 19 1 1 0 0]
- [9 20 0.98 1 1 0]
- [10 11 0.98 1 1 0]
- [10 12 0.96 0.96 2 0]
- [10 13 0.94 0.96 3 0]
- [10 14 0.92 0.92 4 0]
- [10 15 0.9 0.92 -5 0]
- [10 16 0.92 0.92 -4 0]
- [10 17 0.94 0.96 -3 0]
- [10 18 0.96 0.96 -2 0]
- [10 19 0.98 1 -1 0]
- [10 20 1 1 0 0]
-]
-def
-
-(unittest) run
-/unittest using
-
-ResetKernel
-
-<< /sort_connections_by_source false /use_compressed_spikes false >> SetKernelStatus
-
-userdict /resolution known { << /resolution resolution >> SetKernelStatus } if
-
-/sources src_layer CreateLayer def
-/targets tgt_layer CreateLayer def
-
-sources targets conns ConnectLayers
-
-/sources_oss osstream ; def
-/targets_oss osstream ; def
-/sources_conns_oss osstream ; def
-
-sources_oss sources DumpLayerNodes ;
-targets_oss targets DumpLayerNodes ;
-sources_conns_oss sources targets /static_synapse DumpLayerConnections ;
-
-/source_layer_result sources_oss str cst 3 Partition def
-/target_layer_result targets_oss str cst 3 Partition def
-/conn_result sources_conns_oss str cst 6 Partition def
-
-{
- source_layer_ref source_layer_result eq
-} assert_or_die
-
-{
- target_layer_ref target_layer_result eq
-} assert_or_die
-
-{
- conn_ref conn_result eq
-} assert_or_die
-
diff --git a/testsuite/unittests/test_weight_delay_free.sli b/testsuite/unittests/test_weight_delay_free.sli
deleted file mode 100644
index f0eaa9c54e..0000000000
--- a/testsuite/unittests/test_weight_delay_free.sli
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * test_weight_delay_free.sli
- *
- * This file is part of NEST.
- *
- * Copyright (C) 2004 The NEST Initiative
- *
- * NEST is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * NEST is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with NEST. If not, see .
- *
- */
-
-
-% this tests checks if weights and delays can be set to
-% arbitrary values within the limits set by resolution
-%
-% It creates a grid with a single row and uses linear functions for weights and delays
-% Expected weights are 1., 0.98, 0.96, 0.94, 0.92, 0.90, 0.88, 0.86, 0.84, 0.82
-% Expected delays with resolution 0.04 are 1.0 0.96 0.96 0.92 0.92 0.88 0.84
-
-[ -4.5 4.5 1.0 ] Range
-{ 0.0 2 arraystore } Map /pos Set
-
-/layer << /positions pos
- /extent [10. 1.]
- /edge_wrap true
- /elements /iaf_psc_alpha
- >> def
-
-/src_layer layer def
-/tgt_layer layer def
-
-<< /constant << /value 1.0 >> >> CreateParameter
-<< /constant << /value -0.02 >> >> CreateParameter
-<< /distance << >> >> CreateParameter
-mul add /linear_parameter Set
-
-/conns << /connection_type (pairwise_bernoulli_on_target)
- /mask << /rectangular << /lower_left [ -0.5 -0.5 ] /upper_right [ 9.5 0.5 ] >> >>
- /weight linear_parameter
- /delay linear_parameter
- >> def
-
-% required to make sure that resolution goes into userdict
-userdict begin
- /resolution 0.04 def
-end
-
-/source_layer_ref
-[
- [1 -4.5 0]
- [2 -3.5 0]
- [3 -2.5 0]
- [4 -1.5 0]
- [5 -0.5 0]
- [6 0.5 0]
- [7 1.5 0]
- [8 2.5 0]
- [9 3.5 0]
- [10 4.5 0]
-]
-def
-
-/target_layer_ref
-[
- [11 -4.5 0]
- [12 -3.5 0]
- [13 -2.5 0]
- [14 -1.5 0]
- [15 -0.5 0]
- [16 0.5 0]
- [17 1.5 0]
- [18 2.5 0]
- [19 3.5 0]
- [20 4.5 0]
-]
-def
-
-/conn_ref
-[
- [1 11 1 1 0 0]
- [1 12 0.98 1 1 0]
- [1 13 0.96 0.96 2 0]
- [1 14 0.94 0.96 3 0]
- [1 15 0.92 0.92 4 0]
- [1 16 0.9 0.92 -5 0]
- [1 17 0.92 0.92 -4 0]
- [1 18 0.94 0.96 -3 0]
- [1 19 0.96 0.96 -2 0]
- [1 20 0.98 1 -1 0]
- [2 11 0.98 1 -1 0]
- [2 12 1 1 0 0]
- [2 13 0.98 1 1 0]
- [2 14 0.96 0.96 2 0]
- [2 15 0.94 0.96 3 0]
- [2 16 0.92 0.92 4 0]
- [2 17 0.9 0.92 -5 0]
- [2 18 0.92 0.92 -4 0]
- [2 19 0.94 0.96 -3 0]
- [2 20 0.96 0.96 -2 0]
- [3 11 0.96 0.96 -2 0]
- [3 12 0.98 1 -1 0]
- [3 13 1 1 0 0]
- [3 14 0.98 1 1 0]
- [3 15 0.96 0.96 2 0]
- [3 16 0.94 0.96 3 0]
- [3 17 0.92 0.92 4 0]
- [3 18 0.9 0.92 -5 0]
- [3 19 0.92 0.92 -4 0]
- [3 20 0.94 0.96 -3 0]
- [4 11 0.94 0.96 -3 0]
- [4 12 0.96 0.96 -2 0]
- [4 13 0.98 1 -1 0]
- [4 14 1 1 0 0]
- [4 15 0.98 1 1 0]
- [4 16 0.96 0.96 2 0]
- [4 17 0.94 0.96 3 0]
- [4 18 0.92 0.92 4 0]
- [4 19 0.9 0.92 -5 0]
- [4 20 0.92 0.92 -4 0]
- [5 11 0.92 0.92 -4 0]
- [5 12 0.94 0.96 -3 0]
- [5 13 0.96 0.96 -2 0]
- [5 14 0.98 1 -1 0]
- [5 15 1 1 0 0]
- [5 16 0.98 1 1 0]
- [5 17 0.96 0.96 2 0]
- [5 18 0.94 0.96 3 0]
- [5 19 0.92 0.92 4 0]
- [5 20 0.9 0.92 -5 0]
- [6 11 0.9 0.92 -5 0]
- [6 12 0.92 0.92 -4 0]
- [6 13 0.94 0.96 -3 0]
- [6 14 0.96 0.96 -2 0]
- [6 15 0.98 1 -1 0]
- [6 16 1 1 0 0]
- [6 17 0.98 1 1 0]
- [6 18 0.96 0.96 2 0]
- [6 19 0.94 0.96 3 0]
- [6 20 0.92 0.92 4 0]
- [7 11 0.92 0.92 4 0]
- [7 12 0.9 0.92 -5 0]
- [7 13 0.92 0.92 -4 0]
- [7 14 0.94 0.96 -3 0]
- [7 15 0.96 0.96 -2 0]
- [7 16 0.98 1 -1 0]
- [7 17 1 1 0 0]
- [7 18 0.98 1 1 0]
- [7 19 0.96 0.96 2 0]
- [7 20 0.94 0.96 3 0]
- [8 11 0.94 0.96 3 0]
- [8 12 0.92 0.92 4 0]
- [8 13 0.9 0.92 -5 0]
- [8 14 0.92 0.92 -4 0]
- [8 15 0.94 0.96 -3 0]
- [8 16 0.96 0.96 -2 0]
- [8 17 0.98 1 -1 0]
- [8 18 1 1 0 0]
- [8 19 0.98 1 1 0]
- [8 20 0.96 0.96 2 0]
- [9 11 0.96 0.96 2 0]
- [9 12 0.94 0.96 3 0]
- [9 13 0.92 0.92 4 0]
- [9 14 0.9 0.92 -5 0]
- [9 15 0.92 0.92 -4 0]
- [9 16 0.94 0.96 -3 0]
- [9 17 0.96 0.96 -2 0]
- [9 18 0.98 1 -1 0]
- [9 19 1 1 0 0]
- [9 20 0.98 1 1 0]
- [10 11 0.98 1 1 0]
- [10 12 0.96 0.96 2 0]
- [10 13 0.94 0.96 3 0]
- [10 14 0.92 0.92 4 0]
- [10 15 0.9 0.92 -5 0]
- [10 16 0.92 0.92 -4 0]
- [10 17 0.94 0.96 -3 0]
- [10 18 0.96 0.96 -2 0]
- [10 19 0.98 1 -1 0]
- [10 20 1 1 0 0]
-]
-def
-
-(unittest) run
-/unittest using
-
-ResetKernel
-
-<< /sort_connections_by_source false /use_compressed_spikes false >> SetKernelStatus
-
-userdict /resolution known { << /resolution resolution >> SetKernelStatus } if
-
-/sources src_layer CreateLayer def
-/targets tgt_layer CreateLayer def
-
-sources targets conns ConnectLayers
-
-/sources_oss osstream ; def
-/targets_oss osstream ; def
-/sources_conns_oss osstream ; def
-
-sources_oss sources DumpLayerNodes ;
-targets_oss targets DumpLayerNodes ;
-sources_conns_oss sources targets /static_synapse DumpLayerConnections ;
-
-/source_layer_result sources_oss str cst 3 Partition def
-/target_layer_result targets_oss str cst 3 Partition def
-/conn_result sources_conns_oss str cst 6 Partition def
-
-{
- source_layer_ref source_layer_result eq
-} assert_or_die
-
-{
- target_layer_ref target_layer_result eq
-} assert_or_die
-
-{
- conn_ref conn_result eq
-} assert_or_die
-