-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathinitialize_net.py
65 lines (53 loc) · 1.65 KB
/
initialize_net.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
def main(self, widget=None):
self.dat = {}
self.dat['nodes'] = {}
self.dat['nodes']['row'] = []
self.dat['nodes']['col'] = []
self.dat['mat'] = []
self.dat['node_info'] = {}
for inst_rc in self.dat['nodes']:
self.dat['node_info'][inst_rc] = {}
self.dat['node_info'][inst_rc]['ini'] = []
self.dat['node_info'][inst_rc]['clust'] = []
self.dat['node_info'][inst_rc]['rank'] = []
self.dat['node_info'][inst_rc]['info'] = []
self.dat['node_info'][inst_rc]['cat'] = []
self.dat['node_info'][inst_rc]['value'] = []
# check if net has categories predefined
if hasattr(self, 'persistent_cat') == False:
self.persistent_cat = False
found_cats = False
else:
found_cats = True
inst_cat_colors = self.viz['cat_colors']
# add widget if necessary
if widget != None:
self.widget_class = widget
self.viz = {}
self.viz['row_nodes'] = []
self.viz['col_nodes'] = []
self.viz['links'] = []
self.viz['mat'] = []
if found_cats == False:
# print('no persistent_cat')
self.viz['cat_colors'] = {}
self.viz['cat_colors']['row'] = {}
self.viz['cat_colors']['col'] = {}
else:
# print('yes persistent_cat')
self.viz['cat_colors'] = inst_cat_colors
self.sim = {}
def viz(self, reset_cat_colors=False):
# keep track of old cat_colors
old_cat_colors = self.viz['cat_colors']
self.viz = {}
self.viz['row_nodes'] = []
self.viz['col_nodes'] = []
self.viz['links'] = []
self.viz['mat'] = []
if reset_cat_colors == True:
self.viz['cat_colors'] = {}
self.viz['cat_colors']['row'] = {}
self.viz['cat_colors']['col'] = {}
else:
self.viz['cat_colors'] = old_cat_colors