Skip to content

Commit 4145f71

Browse files
authored
Merge pull request #125 from neurolib-dev/fix/multimodel_tests
Fix MultiModel tests
2 parents c4d9512 + 6b0dc58 commit 4145f71

File tree

6 files changed

+40
-13
lines changed

6 files changed

+40
-13
lines changed

examples/example-0.6-custom-model.ipynb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@
2929
"%autoreload 2"
3030
]
3131
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"try:\n",
39+
" import matplotlib.pyplot as plt\n",
40+
"except ImportError:\n",
41+
" import sys\n",
42+
" !{sys.executable} -m pip install matplotlib\n",
43+
" import matplotlib.pyplot as plt"
44+
]
45+
},
3246
{
3347
"cell_type": "markdown",
3448
"metadata": {},
@@ -223,7 +237,6 @@
223237
}
224238
],
225239
"source": [
226-
"import matplotlib.pyplot as plt\n",
227240
"plt.plot(model.t, model.output.T);\n",
228241
"plt.xlabel(\"Time [ms]\")\n",
229242
"plt.ylabel(\"Activity $x$\")"

tests/multimodel/test_fitzhugh_nagumo.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
SEED = 42
2020
DURATION = 100.0
2121
DT = 0.1
22-
CORR_THRESHOLD = 0.99
22+
CORR_THRESHOLD = 0.95
2323
NEUROLIB_VARIABLES_TO_TEST = ["x", "y"]
2424

2525
# dictionary as backend name: format in which the noise is passed
@@ -110,7 +110,9 @@ def test_compare_w_neurolib_native_model(self):
110110
"""
111111
# run this model
112112
fhn_multi = self._create_node()
113-
multi_result = fhn_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
113+
multi_result = fhn_multi.run(
114+
DURATION, DT, ZeroInput(fhn_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
115+
)
114116
# run neurolib's model
115117
fhn = FHNModel(seed=SEED)
116118
fhn.params["duration"] = DURATION
@@ -159,7 +161,9 @@ def test_compare_w_neurolib_native_model(self):
159161
"""
160162
# run this model - default is diffusive coupling
161163
fhn_multi = FitzHughNagumoNetwork(self.SC, self.DELAYS, seed=SEED)
162-
multi_result = fhn_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
164+
multi_result = fhn_multi.run(
165+
DURATION, DT, ZeroInput(fhn_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
166+
)
163167
# run neurolib's model
164168
fhn_neurolib = FHNModel(Cmat=self.SC, Dmat=self.DELAYS, seed=SEED)
165169
fhn_neurolib.params["duration"] = DURATION

tests/multimodel/test_hopf.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
SEED = 42
1414
DURATION = 100.0
1515
DT = 0.1
16-
CORR_THRESHOLD = 0.99
16+
CORR_THRESHOLD = 0.95
1717
NEUROLIB_VARIABLES_TO_TEST = ["x", "y"]
1818

1919
# dictionary as backend name: format in which the noise is passed
@@ -104,7 +104,9 @@ def test_compare_w_neurolib_native_model(self):
104104
"""
105105
# run this model
106106
hopf_multi = self._create_node()
107-
multi_result = hopf_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
107+
multi_result = hopf_multi.run(
108+
DURATION, DT, ZeroInput(hopf_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
109+
)
108110
# run neurolib's model
109111
hopf_neurolib = HopfModel(seed=SEED)
110112
hopf_neurolib.params["duration"] = DURATION
@@ -153,7 +155,9 @@ def test_compare_w_neurolib_native_model(self):
153155
"""
154156
# run this model - default is diffusive coupling
155157
hopf_multi = HopfNetwork(self.SC, self.DELAYS, seed=SEED)
156-
multi_result = hopf_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
158+
multi_result = hopf_multi.run(
159+
DURATION, DT, ZeroInput(hopf_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
160+
)
157161
# run neurolib's model
158162
hopf_neurolib = HopfModel(Cmat=self.SC, Dmat=self.DELAYS, seed=SEED)
159163
hopf_neurolib.params["duration"] = DURATION

tests/multimodel/test_thalamus.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
DURATION = 100.0
2121
DT = 0.01
22-
CORR_THRESHOLD = 0.95
22+
CORR_THRESHOLD = 0.9
2323
NEUROLIB_VARIABLES_TO_TEST = [
2424
("r_mean_EXC", "Q_t"),
2525
("r_mean_INH", "Q_r"),
@@ -139,7 +139,9 @@ def test_compare_w_neurolib_native_model(self):
139139
"""
140140
# run this model
141141
thalamus_multi = self._create_node()
142-
multi_result = thalamus_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
142+
multi_result = thalamus_multi.run(
143+
DURATION, DT, ZeroInput(thalamus_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
144+
)
143145
# run neurolib's model
144146
thlm_neurolib = ThalamicMassModel()
145147
thlm_neurolib.params["duration"] = DURATION

tests/multimodel/test_wilson_cowan.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SEED = 42
2323
DURATION = 100.0
2424
DT = 0.01
25-
CORR_THRESHOLD = 0.93
25+
CORR_THRESHOLD = 0.9
2626
NEUROLIB_VARIABLES_TO_TEST = [("q_mean_EXC", "exc"), ("q_mean_INH", "inh")]
2727

2828
# dictionary as backend name: format in which the noise is passed
@@ -130,7 +130,9 @@ def test_compare_w_neurolib_native_model(self):
130130
"""
131131
# run this model
132132
wc_multi = self._create_node()
133-
multi_result = wc_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
133+
multi_result = wc_multi.run(
134+
DURATION, DT, ZeroInput(wc_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
135+
)
134136
# run neurolib's model
135137
wc_neurolib = WCModel(seed=SEED)
136138
wc_neurolib.params["duration"] = DURATION
@@ -183,7 +185,9 @@ def test_compare_w_neurolib_native_model(self):
183185
Compare with neurolib's native Wilson-Cowan model.
184186
"""
185187
wc_multi = WilsonCowanNetwork(self.SC, self.DELAYS)
186-
multi_result = wc_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
188+
multi_result = wc_multi.run(
189+
DURATION, DT, ZeroInput(wc_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
190+
)
187191
# run neurolib's model
188192
wc_neurolib = WCModel(Cmat=self.SC, Dmat=self.DELAYS, seed=SEED)
189193
wc_neurolib.params["duration"] = DURATION

tests/multimodel/test_wong_wang.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
SEED = 42
2525
DURATION = 100.0
2626
DT = 0.1
27-
CORR_THRESHOLD = 0.95
27+
CORR_THRESHOLD = 0.9
2828

2929
# dictionary as backend name: format in which the noise is passed
3030
BACKENDS_TO_TEST = {

0 commit comments

Comments
 (0)