-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultitest.py
65 lines (53 loc) · 1.59 KB
/
multitest.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
import multiprocessing
import itertools
import glob
import os
epsilon = 0.0000001
fileBaseNames = [
"distributeART",
"distributeCondoms",
"addBirths",
"subtractDeaths",
"agePop",
"progressDisease",
"mixing_matrix",
"lambda_mat",
"adjusted_partners",
"transmit",
"endPop",
"riskAdjust"
]
def doSequence(fileBaseName):
fileList = glob.glob('./cout/*.cout')
if fileList:
used_numbers = []
for f in fileList:
try:
file_number = int(os.path.splitext(os.path.basename(f))[0].split('_')[-1])
used_numbers.append(file_number)
except ValueError:
pass
nSteps = max(used_numbers) + 1
else:
return "Failed: no files in ./cout found"
for i in range(nSteps):
baseWithInt = fileBaseName + "_%i" % i
f1 = open("rout/" + baseWithInt + ".out")
f2 = open("cout/" + baseWithInt + ".cout")
row = 0
for line1, line2 in itertools.izip(f1, f2):
row += 1
for val1, val2 in zip(line1.split(","), line2.split(",")):
if abs(float(val1) - float(val2) > epsilon):
f1.close()
f2.close()
return "%s failed at time %i on row: %i" % (baseWithInt, i, row)
f1.close()
f2.close()
return "%s passed at all time steps" % baseWithInt
if __name__ == "__main__":
ncores = multiprocessing.cpu_count() - 1
p = multiprocessing.Pool(ncores)
output = p.map(doSequence, fileBaseNames)
for line in output:
print line