Last change
on this file since 36 was
29,
checked in by gnappo, 14 years ago
|
Taggata versione per la demo e aggiunto branch.
|
-
Property svn:executable set to
*
|
File size:
1.4 KB
|
Rev | Line | |
---|
[29] | 1 | #!/usr/bin/python |
---|
| 2 | |
---|
| 3 | import statistics |
---|
| 4 | import xml.dom.minidom |
---|
| 5 | import sys |
---|
| 6 | import re |
---|
| 7 | from re import split |
---|
| 8 | from math import sqrt |
---|
| 9 | import os |
---|
| 10 | |
---|
| 11 | def getText(nodelist): |
---|
| 12 | rc = [] |
---|
| 13 | for node in nodelist: |
---|
| 14 | if node.nodeType == node.TEXT_NODE: |
---|
| 15 | rc.append(node.data) |
---|
| 16 | return ''.join(rc) |
---|
| 17 | |
---|
| 18 | def handleCluster(cluster): |
---|
| 19 | numberOfVertices = getText(cluster.getElementsByTagName("vertex")[0].childNodes) |
---|
| 20 | conductance = getText(cluster.getElementsByTagName("conductance")[0].childNodes) |
---|
| 21 | print numberOfVertices + " " + conductance |
---|
| 22 | |
---|
| 23 | def handleClusters(clusters): |
---|
| 24 | for cluster in clusters.getElementsByTagName("cluster"): |
---|
| 25 | handleCluster(cluster) |
---|
| 26 | |
---|
| 27 | def handleRun(run): |
---|
| 28 | clusters = run.getElementsByTagName("clusters")[0] |
---|
| 29 | handleClusters(clusters) |
---|
| 30 | |
---|
| 31 | fileXML = sys.argv[1] |
---|
| 32 | dom = xml.dom.minidom.parse(fileXML) |
---|
| 33 | handleRun(dom) |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | #basedir = sys.argv[1] |
---|
| 43 | |
---|
| 44 | #filesList = [basedir + file for file in os.listdir(basedir) if (re.match('.*dat$', file) and not re.match('^output.*', file))] |
---|
| 45 | |
---|
| 46 | #results = [] |
---|
| 47 | #for file in filesList: |
---|
| 48 | # inp = open(file,"r") |
---|
| 49 | # values = [] |
---|
| 50 | # for line in inp.readlines(): |
---|
| 51 | # values.append(float(line)) |
---|
| 52 | # inp.close() |
---|
| 53 | # print "File ",file," acquisito." |
---|
| 54 | # results.append(statistics.mean(values)) |
---|
| 55 | #variance = statistics.variance(results, mode = "Unbiased") |
---|
| 56 | #confidence = sqrt(variance / len(results)) * 1.6449 |
---|
| 57 | #print "Average: ",statistics.mean(results)," Confidence interval: ",confidence |
---|
Note: See
TracBrowser
for help on using the repository browser.