Author: sleon
Date: 2006-01-07 14:01:53 +0000 (Sat, 07 Jan 2006)
New Revision: 7798
Modified:
trunk/apps/freeviz/histogram.py
Log:
removed error hiding except(pass) and packed everything to a function
Modified: trunk/apps/freeviz/histogram.py
===================================================================
--- trunk/apps/freeviz/histogram.py 2006-01-07 13:57:22 UTC (rev 7797)
+++ trunk/apps/freeviz/histogram.py 2006-01-07 14:01:53 UTC (rev 7798)
@@ -2,44 +2,44 @@
precision=10
-try:
- import gdchart
- from math import floor
- import sys
- sys.path+=['/home/sleon/public_html/bla/']
+import gdchart
+from math import floor
+import sys
+sys.path+=['/home/sleon/public_html/bla/']
- import histdata
+import histdata
- links = histdata.get()
-except:
- pass
-histogram=[]
-for x in range(0,precision):
- histogram.append(0)
-number_of_connections=len(links)
-#print "They are "+str(number_of_connections)+" connections."
+def gen():
+ links = histdata.get()
-for connection in links:
-
delta=float(connection[0].get("location"))-float(connection[1].get("location"))
- index=int(floor(abs(delta*precision)))
- histogram[index]=histogram[index]+1
-
-histogram_percents=[ (x*100)/number_of_connections for x in histogram ]
-
-x = gdchart.Bar3D()
-x.width = 250
-x.height = 250
-x.xtitle = "Distance"
-x.ytitle = "%"
-x.title = "Histogram of link location distances"
-x.ext_color = [ 0x055202 , 0x169310 , 0x298760 , 0x297987 , 0xc1d72b ,
0xd4f113 , 0xf18113 , 0xf13713 , 0xcf0000 , 0x000000 ]
-x.setData(histogram_percents)
-label=[]
-for column_name in range(0,precision):
- label.append(str(column_name))
-x.setLabels(label)
-x.draw("/tmp/histogram.png")
-#print histogram
-#print histogram_percents
+ histogram=[]
+ for x in range(0,precision):
+ histogram.append(0)
+ number_of_connections=len(links)
+
+ #print "They are "+str(number_of_connections)+" connections."
+
+ for connection in links:
+
delta=float(connection[0].get("location"))-float(connection[1].get("location"))
+ index=int(floor(abs(delta*precision)))
+ histogram[index]=histogram[index]+1
+
+ histogram_percents=[ (x*100)/number_of_connections for x in histogram ]
+
+ x = gdchart.Bar3D()
+ x.width = 250
+ x.height = 250
+ x.xtitle = "Distance"
+ x.ytitle = "%"
+ x.title = "Histogram of link location distances"
+ x.ext_color = [ 0x055202 , 0x169310 , 0x298760 , 0x297987 , 0xc1d72b ,
0xd4f113 , 0xf18113 , 0xf13713 , 0xcf0000 , 0x000000 ]
+ x.setData(histogram_percents)
+ label=[]
+ for column_name in range(0,precision):
+ label.append(str(column_name))
+ x.setLabels(label)
+ x.draw("/tmp/histogram.png")
+ #print histogram
+ #print histogram_percents