~tfardet/NNGT

f2dc429c7770e3a8e5f7a0c1c107c05bfe9458d2 — Tanguy Fardet 1 year, 8 months ago 552f047
Bugfix - Spectral radius, NEST support

Fix spectral radius for unweighted graphs.
Fix save_spikes.
Improved support for receptor_ports with conductance-based synapses.
M doc/developer/library_shipping.rst => doc/developer/library_shipping.rst +1 -1
@@ 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"


M nngt/analysis/graph_analysis.py => nngt/analysis/graph_analysis.py +2 -1
@@ 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:

M nngt/simulation/nest_graph.py => nngt/simulation/nest_graph.py +11 -3
@@ 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

M nngt/simulation/nest_utils.py => nngt/simulation/nest_utils.py +7 -5
@@ 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})