@@ -114,7 +114,8 @@ def _edge_info(self, mod_e=None, mod_a=None, index=None):
114
114
mod_a [m ] = perc_btwn + perc_within #all of the A's
115
115
#mod_e.append(perc_within)
116
116
#mod_a.append(perc_btwn+perc_within)
117
-
117
+ if np .isnan (mod_e [m ]) or np .isnan (mod_a [m ]):
118
+ 1 / 0
118
119
119
120
return mod_e , mod_a
120
121
@@ -129,6 +130,8 @@ def modularity_newman(self):
129
130
Returns:
130
131
mod = modularity
131
132
"""
133
+ if np .isnan ((np .array (self .mod_e ) - (np .array (self .mod_a )** 2 )).sum ()):
134
+ 1 / 0
132
135
return (np .array (self .mod_e ) - (np .array (self .mod_a )** 2 )).sum ()
133
136
134
137
modularity = modularity_newman
@@ -853,6 +856,7 @@ def plot_partition(g,part,title,fname='figure',nod_labels = None, pos = None,
853
856
for v in val :
854
857
if les_dam != 'none' :
855
858
plt .scatter (pos [v ][0 ],pos [v ][1 ],s = 100 * les_dam [v ],c = 'orange' ,marker = (10 ,1 ,0 ))
859
+
856
860
nx .draw_networkx_nodes (g ,pos ,nodelist = list (val ),node_color = col [niter ],node_size = 50 )
857
861
else :
858
862
for v in val :
@@ -870,6 +874,7 @@ def plot_partition(g,part,title,fname='figure',nod_labels = None, pos = None,
870
874
for v in val :
871
875
if les_dam != 'none' :
872
876
plt .scatter (pos [v ][0 ],pos [v ][1 ],s = 100 * les_dam [v ],c = 'orange' ,marker = (10 ,1 ,0 ))
877
+
873
878
nx .draw_networkx_nodes (g ,pos ,nodelist = list (val ),node_color = col2 [niter ],node_size = 50 )
874
879
else :
875
880
for v in val :
@@ -918,8 +923,8 @@ def plot_partition(g,part,title,fname='figure',nod_labels = None, pos = None,
918
923
for m ,val in part .iteritems ():
919
924
for v in val :
920
925
if les_dam [v ] > 0 :
921
- plt .scatter (pos [v ][0 ],pos [v ][1 ],s = 500 * les_dam [v ]+ 100 ,c = 'orange' ,marker = (4 ,1 ,0 ))
922
-
926
+ plt .scatter (pos [v ][0 ],pos [v ][1 ],s = 500 * les_dam [v ]+ 100 ,c = 'orange' ,marker = (10 ,1 ,0 ))
927
+
923
928
plt .title (title )
924
929
#plt.savefig(fname)
925
930
#plt.close()
@@ -1071,7 +1076,7 @@ def simulated_annealing(g,temperature = 50, temp_scaling = 0.995, tmin=1e-5,
1071
1076
1072
1077
energy = - graph_partition .modularity ()
1073
1078
energy_array .append (energy )
1074
-
1079
+
1075
1080
while temperature > tmin :
1076
1081
# Initialize counters
1077
1082
bad_accept_mod = 0
@@ -1249,8 +1254,8 @@ def simulated_annealing(g,temperature = 50, temp_scaling = 0.995, tmin=1e-5,
1249
1254
npt .assert_almost_equal (debug_partition .modularity (),
1250
1255
graph_part_final .modularity (), 11 )
1251
1256
1252
- for mod in graph_partition_final .index :
1253
- if len (graph_partition_final .index [mod ]) < 1 :
1257
+ for mod in graph_part_final .index :
1258
+ if len (graph_part_final .index [mod ]) < 1 :
1254
1259
raise ValueError ('LAST CHECK: Empty module after module %s,SA' % (movetype ))
1255
1260
1256
1261
if extra_info :
0 commit comments