From 9f5102848b756dc356b8d4dbb8f8b592012edc34 Mon Sep 17 00:00:00 2001 From: Maximilian Schmidt <max.schmidt@fz-juelich.de> Date: Mon, 16 Apr 2018 10:45:47 +0900 Subject: [PATCH] Properly raise a NotImplementedError if trying to use the not yet implemented stabilization procedure and test for this Exclude parameters with explicit paths from label determination of classes because they might differ between systems --- multiarea_model/multiarea_model.py | 12 ++++++++++-- tests/test_stabilization.py | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/test_stabilization.py diff --git a/multiarea_model/multiarea_model.py b/multiarea_model/multiarea_model.py index fb7c0a1..6eb06a4 100644 --- a/multiarea_model/multiarea_model.py +++ b/multiarea_model/multiarea_model.py @@ -136,7 +136,8 @@ class MultiAreaModel: self.K = ind else: if self.params['connection_params']['K_stable'] is True: - print('Stabilization procedure has to be integrated.') + raise NotImplementedError('Stabilization procedure has ' + 'to be integrated.') elif isinstance(self.params['connection_params']['K_stable'], np.ndarray): raise ValueError("Not supported. Please store the " "matrix in a file and define the path to the file as " @@ -160,7 +161,14 @@ class MultiAreaModel: self.label = dicthash.generate_hash_from_dict({'params': self.params, 'K': self.K, 'N': self.N, - 'structure': self.structure}) + 'structure': self.structure}, + blacklist=[('params', 'fullscale_rates'), + ('params', + 'connection_params', + 'K_stable'), + ('params', + 'connection_params', + 'replace_cc_input_source')]) if isinstance(network_spec, dict): parameter_fn = os.path.join(base_path, diff --git a/tests/test_stabilization.py b/tests/test_stabilization.py new file mode 100644 index 0000000..ddedbb9 --- /dev/null +++ b/tests/test_stabilization.py @@ -0,0 +1,15 @@ +from multiarea_model import MultiAreaModel +import pytest + + +def test_meanfield(): + """ + Test stabilization procedure. Since this algorithm is not + implemented yet, we here test if this properly raises a + NotImplementedError. + """ + + network_params = {'connection_params': {'K_stable': True}} + theory_params = {} + with pytest.raises(NotImplementedError): + MultiAreaModel(network_params, theory=True, theory_spec=theory_params) -- GitLab