-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_complexnetwork.py
116 lines (91 loc) · 3.14 KB
/
test_complexnetwork.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import unittest
import pickle
import numpy as np
from complexnetwork import (
avalanche,
ising,
power_law,
)
from complexnetwork import utils
# Getting back the pickled matrices:
with open("sample_matrices.pkl", "rb") as f:
(
matrices_dict,
Exc_activity,
Inh_activity,
Rec_activity,
num_active_connections,
) = pickle.load(f)
X = np.asarray(Exc_activity)
activity_threshold = 1
window_sizes = [1, 2, 5]
class TestCompNet(unittest.TestCase):
def test_avalanche(self):
self.assertRaises(
Exception,
avalanche.Avalanches().avalanche_observables(
X, activity_threshold=activity_threshold
),
)
(
avalanches,
avalanche_durations,
avalanche_sizes,
iai,
) = avalanche.Avalanches().avalanche_observables(
X, activity_threshold=activity_threshold
)
self.assertRaises(Exception, avalanche.Avalanches().plot(avalanches))
self.assertRaises(
Exception,
avalanche.Avalanches().durations_histogram(avalanche_durations, plot=True),
)
self.assertRaises(
Exception, avalanche.Avalanches().size_histogram(avalanche_sizes, plot=True)
)
self.assertRaises(
Exception, avalanche.Avalanches().iai_histogram(iai, plot=True)
)
def test_branching_factor(self):
pass
def test_exponential_relationships(self):
pass
def test_ising(self):
self.assertRaises(
Exception, ising.IsingModel().compute_spin(X, window_sizes=window_sizes)
)
self.assertRaises(
Exception,
ising.IsingModel().mean_spiking_activity(X, window_sizes=window_sizes),
)
self.assertRaises(
Exception, ising.IsingModel().compute_Q(X, window_sizes=window_sizes)
)
Q, _ = ising.IsingModel().compute_Q(X, window_sizes=window_sizes)
self.assertRaises(
Exception, ising.IsingModel().compute_Q(X, window_sizes=window_sizes)
)
self.assertRaises(Exception, ising.IsingModel().plotQ(Q))
def test_powerlaw(self):
(_, _, avalanche_sizes, _,) = avalanche.Avalanches().avalanche_observables(
X, activity_threshold=activity_threshold
)
avalanche_size_hist = avalanche.Avalanches().size_histogram(avalanche_sizes)
xmin = 1
# Avalanche histogram
x = avalanche_size_hist[1]
a, b = 1.01, 10
# Exponent estimate
self.assertRaises(Exception, power_law.PowerLaw().exponent(x, xmin, a, b))
alpha_hat = power_law.PowerLaw().exponent(x, xmin, a, b)
# Confidence interval of the above estimate, assuming the network shows at n, the avalanche behavoir kicks in
self.assertRaises(
Exception,
power_law.PowerLaw().confidence_interval(n=1.0, alpha_hat=alpha_hat),
)
def test_scaling_functions(self):
pass
def test_utils(self,):
self.assertRaises(Exception, utils.compute_spike_count(X))
if __name__ == "__main__":
unittest.main()