Skip to content
Snippets Groups Projects
Unverified Commit e17707ec authored by Sacha van Albada's avatar Sacha van Albada Committed by GitHub
Browse files

Merge pull request #8 from INM-6/fix/stabilization_msg

Fix message about stabilization
parents eda68e7a 7074a6ab
No related branches found
No related tags found
No related merge requests found
......@@ -76,7 +76,7 @@ later release of NEST, version 2.14.0 .
This class can be initialized by `MultiAreaModel` or as standalone and
takes simulation parameters as input. It provides two main features:
- predict the stable fixed point of the system using mean-field theory and characterize them (for instance by computing the gain matrix).
- via the script `stabilize.py`, one can execute the stabilization method described in [2] on a network instance.
- via the script `stabilize.py`, one can execute the stabilization method described in [2] on a network instance. Please see `figures/SchueckerSchmidt2017/stabilization.py` for an example of running the stabilization.
`Analysis`
......
......@@ -132,18 +132,15 @@ class MultiAreaModel:
ind, inda, out, outa = load_degree_data(tmp_data_fn)
# If K_stable is specified in the params, load the stabilized matrix
# TODO: Extend this by calling the stabilization method
if not self.params['connection_params']['K_stable']:
if self.params['connection_params']['K_stable'] is None:
self.K = ind
else:
if self.params['connection_params']['K_stable'] is True:
raise NotImplementedError('Stabilization procedure has '
'to be integrated.')
elif isinstance(self.params['connection_params']['K_stable'], np.ndarray):
raise NotImplementedError("Not supported. Please store the "
"matrix in a file and define the path to the file as "
"the parameter value.")
else: # Assume that the parameter defines a filename containing the matrix
K_stable = np.load(self.params['connection_params']['K_stable'])
if not isinstance(self.params['connection_params']['K_stable'], str):
raise TypeError("Not supported. Please store the "
"matrix in a binary numpy file and define "
"the path to the file as the parameter value.")
# Assume that the parameter defines a filename containing the matrix
K_stable = np.load(self.params['connection_params']['K_stable'])
ext = {area: {pop: ind[area][pop]['external'] for pop in
self.structure['V1']} for area in self.area_list}
self.K = matrix_to_dict(
......
from multiarea_model import MultiAreaModel
import numpy as np
import pytest
from multiarea_model import MultiAreaModel
def test_meanfield():
def test_stabilization():
"""
Test stabilization procedure. Since this algorithm is not
implemented yet, we here test if this properly raises a
NotImplementedError.
Test stabilization procedure. The stabilized matrix is expected to
be stored in a file and the parameter in the dictionary specifies
the corresponding name. We here check if the MultiAreaModel class
properly throws a TypeError when we try to directly specify the
matrix.
"""
network_params = {'connection_params': {'K_stable': True}}
# Create random matrix for indegrees
K_stable = np.random.rand(254, 254)
np.save('K_stable_test.npy', K_stable)
# Trying to directly specify the matrix should throw a TypeError.
network_params = {'connection_params': {'K_stable': K_stable}}
theory_params = {}
with pytest.raises(NotImplementedError):
with pytest.raises(TypeError):
MultiAreaModel(network_params, theory=True, theory_spec=theory_params)
# Specifying the file name leads to the correct indegrees being loaded.
network_params = {'connection_params': {'K_stable': 'K_stable_test.npy'}}
theory_params = {}
M = MultiAreaModel(network_params, theory=True, theory_spec=theory_params)
assert(np.all(K_stable == M.K_matrix[:, :-1]))
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment