~tfardet/nngt-developers

NNGT: Bugfix - Spectral radius, NEST support v2 APPLIED

~tfardet
~tfardet: 1
 Bugfix - Spectral radius, NEST support

 4 files changed, 21 insertions(+), 10 deletions(-)
#578729 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~tfardet/nngt-developers/patches/24862/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH NNGT v2] Bugfix - Spectral radius, NEST support Export this patch

~tfardet
From: Tanguy Fardet <tanguyfardet@protonmail.com>

Fix spectral radius for unweighted graphs.
Fix save_spikes.
Improved support for receptor_ports with conductance-based synapses.
---
 doc/developer/library_shipping.rst |  2 +-
 nngt/analysis/graph_analysis.py    |  3 ++-
 nngt/simulation/nest_graph.py      | 14 +++++++++++---
 nngt/simulation/nest_utils.py      | 12 +++++++-----
 4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/doc/developer/library_shipping.rst b/doc/developer/library_shipping.rst
index e722daf..e2fec68 100755
--- a/doc/developer/library_shipping.rst
+++ b/doc/developer/library_shipping.rst
@@ -75,7 +75,7 @@ https://twine.readthedocs.io/en/latest/
First test it:

    twine upload --repository-url https://test.pypi.org/legacy/ *
    pip install --user --index-url https://test.pypi.org/simple/ nngt
    pip install --index-url https://test.pypi.org/simple/ nngt

Then upload "for real"

diff --git a/nngt/analysis/graph_analysis.py b/nngt/analysis/graph_analysis.py
index 2e6e225..9437aa8 100755
--- a/nngt/analysis/graph_analysis.py
+++ b/nngt/analysis/graph_analysis.py
@@ -809,7 +809,8 @@ def spectral_radius(graph, typed=True, weights=True):
    -------
    the spectral radius as a float.
    '''
    mat_adj  = graph.adjacency_matrix(types=typed, weights=weights)
    mat_adj  = graph.adjacency_matrix(types=typed,
                                      weights=weights).astype(float)
    eigenval = []

    try:
diff --git a/nngt/simulation/nest_graph.py b/nngt/simulation/nest_graph.py
index aa218ad..560fee4 100755
--- a/nngt/simulation/nest_graph.py
+++ b/nngt/simulation/nest_graph.py
@@ -108,7 +108,7 @@ def make_nest_network(network, send_only=None, weights=True):

            for key, val in group.neuron_param.items():
                if key in defaults and key != "model":
                    if nonstring_container(val):
                    if nonstring_container(val) and len(val) == group_size:
                        ns_param[key] = val
                    else:
                        scalar_param[key] = val
@@ -175,12 +175,20 @@ def make_nest_network(network, send_only=None, weights=True):
                    syn_spec = _get_syn_param(
                        src_name, src_group, tgt_name, tgt_group, pop.syn_spec)

                    # check whether sign must be given or not
                    local_sign = syn_sign
                    if "receptor_type" in syn_spec:
                        if "cond" in tgt_group.neuron_model:
                            # do not specify the sign for conductance-based
                            # multisynapse model
                            local_sign = 1

                    # using A1 to get data from matrix
                    if weights:
                        syn_spec[WEIGHT] = syn_sign *\
                        syn_spec[WEIGHT] = local_sign *\
                            csr_weights[local_src_ids, local_tgt_ids].A1
                    else:
                        syn_spec[WEIGHT] = np.repeat(syn_sign, len(tgt_ids))
                        syn_spec[WEIGHT] = np.repeat(local_sign, len(tgt_ids))
    
                    syn_spec[DELAY] = \
                        csr_delays[local_src_ids, local_tgt_ids].A1
diff --git a/nngt/simulation/nest_utils.py b/nngt/simulation/nest_utils.py
index 6d39560..9da02b9 100755
--- a/nngt/simulation/nest_utils.py
+++ b/nngt/simulation/nest_utils.py
@@ -502,14 +502,16 @@ def save_spikes(filename, recorder=None, network=None, save_positions=True,

            if nest_version == 3:
                if len(rcrdrs) == 1:
                    assert recrdrs.model == spike_rec, \
                    assert rcrdrs.model == spike_rec, \
                        'Only spike_detectors are supported.'
                    assert recrdrs.model == (spike_rec,)*len(rcrdrs), \
                else:
                    assert rcrdrs.model == (spike_rec,)*len(rcrdrs), \
                        'Only spike_detectors are supported.'
            else:
                assert (nest.GetStatus(rcrdrs, 'model')
                        == ('spike_detector',)*len(rcrdrs)), \
                       'Only spike_detectors are supported.'
                for rec in rcrdrs:
                    assert (nest.GetStatus(rec, 'model')
                            == ('spike_detector',)*len(rec)), \
                           'Only spike_detectors are supported.'
    else:
        if nest_version == 3:
            rcrdrs = nest.GetNodes(properties={'model': spike_rec})
-- 
2.32.0
builds.sr.ht
NNGT/patches/.build.yml: SUCCESS in 27m0s

[Bugfix - Spectral radius, NEST support][0] v2 from [~tfardet][1]

[0]: https://lists.sr.ht/~tfardet/nngt-developers/patches/24862
[1]: mailto:tanguyfardet@protonmail.com

✓ #578729 SUCCESS NNGT/patches/.build.yml https://builds.sr.ht/~tfardet/job/578729