1
|
|
|
"""!
|
2
|
|
|
|
3
|
|
|
@brief Unit-tests for oscillatory network based on Hodgkin-Huxley model of neuron.
|
4
|
|
|
|
5
|
|
|
@authors Andrei Novikov ([email protected])
|
6
|
|
|
@date 2014-2016
|
7
|
|
|
@copyright GNU Public License
|
8
|
|
|
|
9
|
|
|
@cond GNU_PUBLIC_LICENSE
|
10
|
|
|
PyClustering is free software: you can redistribute it and/or modify
|
11
|
|
|
it under the terms of the GNU General Public License as published by
|
12
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
13
|
|
|
(at your option) any later version.
|
14
|
|
|
|
15
|
|
|
PyClustering is distributed in the hope that it will be useful,
|
16
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
|
|
GNU General Public License for more details.
|
19
|
|
|
|
20
|
|
|
You should have received a copy of the GNU General Public License
|
21
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
22
|
|
|
@endcond
|
23
|
|
|
|
24
|
|
|
"""
|
25
|
|
|
|
26
|
|
|
import unittest;
|
27
|
|
|
|
28
|
|
|
from pyclustering.utils import extract_number_oscillations;
|
29
|
|
|
|
30
|
|
|
from pyclustering.nnet.hhn import hhn_network, hhn_parameters;
|
31
|
|
|
|
32
|
|
|
class Test(unittest.TestCase):
|
33
|
|
|
# Tests regarded to synchronous ensembles allocation.
|
34
|
|
|
def templateSyncEnsembleAllocation(self, stimulus, params, sim_steps, sim_time, expected_clusters):
|
35
|
|
|
result_testing = False;
|
36
|
|
|
|
37
|
|
|
for attempt in range(0, 2, 1):
|
38
|
|
|
net = hhn_network(len(stimulus), stimulus, params);
|
39
|
|
|
(t, x) = net.simulate(sim_steps, sim_time);
|
40
|
|
|
|
41
|
|
|
ensembles = net.allocate_sync_ensembles(1.0);
|
42
|
|
|
if (ensembles != expected_clusters):
|
43
|
|
|
continue;
|
44
|
|
|
|
45
|
|
|
result_testing = True;
|
46
|
|
|
break;
|
47
|
|
|
|
48
|
|
|
assert result_testing;
|
49
|
|
|
|
50
|
|
|
def testGlobalSyncWithSameStimulus(self):
|
51
|
|
|
self.templateSyncEnsembleAllocation([27, 27, 27], None, 300, 50, [[0, 1, 2]]);
|
52
|
|
|
|
53
|
|
|
def testGlobalSyncWithVariousStimulus(self):
|
54
|
|
|
self.templateSyncEnsembleAllocation([26, 26, 27, 27, 26, 25], None, 300, 50, [[0, 1, 2, 3, 4, 5]]);
|
55
|
|
|
|
56
|
|
|
def testPartialSync(self):
|
57
|
|
|
self.templateSyncEnsembleAllocation([25, 25, 50, 50], None, 400, 200, [ [0, 1], [2, 3] ]);
|
58
|
|
|
|
59
|
|
|
if __name__ == "__main__":
|
60
|
|
|
unittest.main(); |