• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision31c3e30fd22f0a0ad951b5ffe92b2b1c7c590050 (tree)
Time2010-06-07 21:45:40
Authorlorenzo
Commiterlorenzo

Log Message

Some improvements to the code: I can now remove self-interactions in
the time-dependent edge list.

Change Summary

Incremental Difference

diff -r 0ec81578f763 -r 31c3e30fd22f Python-codes/P_tab_tac.py
--- a/Python-codes/P_tab_tac.py Fri Jun 04 11:02:27 2010 +0000
+++ b/Python-codes/P_tab_tac.py Mon Jun 07 12:45:40 2010 +0000
@@ -23,6 +23,16 @@
2323 return new_info
2424
2525
26+def remove_self_loops(clean_data):
27+ sel=s.where(clean_data[:,1]!=clean_data[:,2])[0]
28+
29+ clean_data_no_int=clean_data[sel,:]
30+
31+ return (clean_data_no_int.astype("int64"))
32+
33+
34+
35+no_self=1
2636
2737 #NB: this code should be used on an edgelist without self-interactions
2838
@@ -30,6 +40,13 @@
3040 info = [map(int, string.split(line)) for line in f.readlines()]
3141 f.close()
3242
43+if (no_self==1):
44+
45+ info=s.array(info, dtype="int64")
46+
47+ info=remove_self_loops(info)
48+
49+ info=info.tolist()
3350
3451 new = get_times(info)
3552 contacts = new.keys()
@@ -70,11 +87,21 @@
7087
7188 all_times=s.asarray(all_times, dtype="int64")
7289
73-n.savetxt("t_ab_t_ac.dat",all_times, fmt='%d')
90+if (no_self==1):
7491
75-sel=s.where(all_times>0)
92+ n.savetxt("t_ab_t_ac_no_self.dat",all_times, fmt='%d')
7693
77-n.savetxt("t_ab_t_ac_no_zero.dat",all_times[sel], fmt='%d')
94+ sel=s.where(all_times>0)
95+
96+ n.savetxt("t_ab_t_ac_no_self_no_zero.dat",all_times[sel], fmt='%d')
97+
98+else :
99+
100+ n.savetxt("t_ab_t_ac.dat",all_times, fmt='%d')
101+
102+ sel=s.where(all_times>0)
103+
104+ n.savetxt("t_ab_t_ac_no_zero.dat",all_times[sel], fmt='%d')
78105
79106
80107 print ("So far so good")