Skip to content

Commit

Permalink
Merge pull request #125 from neurolib-dev/fix/multimodel_tests
Browse files Browse the repository at this point in the history
Fix MultiModel tests
  • Loading branch information
caglorithm authored Jan 20, 2021
2 parents c4d9512 + 6b0dc58 commit 4145f71
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
15 changes: 14 additions & 1 deletion examples/example-0.6-custom-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" import matplotlib.pyplot as plt\n",
"except ImportError:\n",
" import sys\n",
" !{sys.executable} -m pip install matplotlib\n",
" import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -223,7 +237,6 @@
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"plt.plot(model.t, model.output.T);\n",
"plt.xlabel(\"Time [ms]\")\n",
"plt.ylabel(\"Activity $x$\")"
Expand Down
10 changes: 7 additions & 3 deletions tests/multimodel/test_fitzhugh_nagumo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
SEED = 42
DURATION = 100.0
DT = 0.1
CORR_THRESHOLD = 0.99
CORR_THRESHOLD = 0.95
NEUROLIB_VARIABLES_TO_TEST = ["x", "y"]

# dictionary as backend name: format in which the noise is passed
Expand Down Expand Up @@ -110,7 +110,9 @@ def test_compare_w_neurolib_native_model(self):
"""
# run this model
fhn_multi = self._create_node()
multi_result = fhn_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
multi_result = fhn_multi.run(
DURATION, DT, ZeroInput(fhn_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
)
# run neurolib's model
fhn = FHNModel(seed=SEED)
fhn.params["duration"] = DURATION
Expand Down Expand Up @@ -159,7 +161,9 @@ def test_compare_w_neurolib_native_model(self):
"""
# run this model - default is diffusive coupling
fhn_multi = FitzHughNagumoNetwork(self.SC, self.DELAYS, seed=SEED)
multi_result = fhn_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
multi_result = fhn_multi.run(
DURATION, DT, ZeroInput(fhn_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
)
# run neurolib's model
fhn_neurolib = FHNModel(Cmat=self.SC, Dmat=self.DELAYS, seed=SEED)
fhn_neurolib.params["duration"] = DURATION
Expand Down
10 changes: 7 additions & 3 deletions tests/multimodel/test_hopf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
SEED = 42
DURATION = 100.0
DT = 0.1
CORR_THRESHOLD = 0.99
CORR_THRESHOLD = 0.95
NEUROLIB_VARIABLES_TO_TEST = ["x", "y"]

# dictionary as backend name: format in which the noise is passed
Expand Down Expand Up @@ -104,7 +104,9 @@ def test_compare_w_neurolib_native_model(self):
"""
# run this model
hopf_multi = self._create_node()
multi_result = hopf_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
multi_result = hopf_multi.run(
DURATION, DT, ZeroInput(hopf_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
)
# run neurolib's model
hopf_neurolib = HopfModel(seed=SEED)
hopf_neurolib.params["duration"] = DURATION
Expand Down Expand Up @@ -153,7 +155,9 @@ def test_compare_w_neurolib_native_model(self):
"""
# run this model - default is diffusive coupling
hopf_multi = HopfNetwork(self.SC, self.DELAYS, seed=SEED)
multi_result = hopf_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
multi_result = hopf_multi.run(
DURATION, DT, ZeroInput(hopf_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
)
# run neurolib's model
hopf_neurolib = HopfModel(Cmat=self.SC, Dmat=self.DELAYS, seed=SEED)
hopf_neurolib.params["duration"] = DURATION
Expand Down
6 changes: 4 additions & 2 deletions tests/multimodel/test_thalamus.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

DURATION = 100.0
DT = 0.01
CORR_THRESHOLD = 0.95
CORR_THRESHOLD = 0.9
NEUROLIB_VARIABLES_TO_TEST = [
("r_mean_EXC", "Q_t"),
("r_mean_INH", "Q_r"),
Expand Down Expand Up @@ -139,7 +139,9 @@ def test_compare_w_neurolib_native_model(self):
"""
# run this model
thalamus_multi = self._create_node()
multi_result = thalamus_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
multi_result = thalamus_multi.run(
DURATION, DT, ZeroInput(thalamus_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
)
# run neurolib's model
thlm_neurolib = ThalamicMassModel()
thlm_neurolib.params["duration"] = DURATION
Expand Down
10 changes: 7 additions & 3 deletions tests/multimodel/test_wilson_cowan.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
SEED = 42
DURATION = 100.0
DT = 0.01
CORR_THRESHOLD = 0.93
CORR_THRESHOLD = 0.9
NEUROLIB_VARIABLES_TO_TEST = [("q_mean_EXC", "exc"), ("q_mean_INH", "inh")]

# dictionary as backend name: format in which the noise is passed
Expand Down Expand Up @@ -130,7 +130,9 @@ def test_compare_w_neurolib_native_model(self):
"""
# run this model
wc_multi = self._create_node()
multi_result = wc_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
multi_result = wc_multi.run(
DURATION, DT, ZeroInput(wc_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
)
# run neurolib's model
wc_neurolib = WCModel(seed=SEED)
wc_neurolib.params["duration"] = DURATION
Expand Down Expand Up @@ -183,7 +185,9 @@ def test_compare_w_neurolib_native_model(self):
Compare with neurolib's native Wilson-Cowan model.
"""
wc_multi = WilsonCowanNetwork(self.SC, self.DELAYS)
multi_result = wc_multi.run(DURATION, DT, ZeroInput().as_array(DURATION, DT), backend="numba")
multi_result = wc_multi.run(
DURATION, DT, ZeroInput(wc_multi.num_noise_variables).as_array(DURATION, DT), backend="numba"
)
# run neurolib's model
wc_neurolib = WCModel(Cmat=self.SC, Dmat=self.DELAYS, seed=SEED)
wc_neurolib.params["duration"] = DURATION
Expand Down
2 changes: 1 addition & 1 deletion tests/multimodel/test_wong_wang.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
SEED = 42
DURATION = 100.0
DT = 0.1
CORR_THRESHOLD = 0.95
CORR_THRESHOLD = 0.9

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

0 comments on commit 4145f71

Please sign in to comment.