-
Notifications
You must be signed in to change notification settings - Fork 0
/
mean_result.py
28 lines (26 loc) · 1.05 KB
/
mean_result.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
import numpy as np
from functools import reduce
with open('result_files/result_table_alpha.txt', 'r') as fr:
result_dict = dict()
result_dict_ = dict()
line = fr.readline()
while line != '':
line_parts = line.split('&')
if len(line_parts) == 1:
line = fr.readline()
continue
if line_parts[0] not in result_dict.keys():
result_dict[line_parts[0]] = np.array([float(x) for x in line_parts[1:]])
else:
result_dict[line_parts[0]] += np.array([float(x) for x in line_parts[1:]])
line = fr.readline()
for key, item in result_dict.items():
print(item)
result_dict_[key] = item / 5
print(result_dict_[key])
with open('result_files/result_table_alpha_mean.txt', 'w') as fw:
for key, item in result_dict_.items():
print(key)
print([str(x) for x in item.tolist()])
print_line = key + '&' + reduce(lambda x, y: x + '&' + y, [("%.2f" % x) for x in item.tolist()]) + r'\\'
print(print_line, file=fw)