-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.py
85 lines (58 loc) · 2 KB
/
results.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import numpy as np
import csv
import json
import os
import datetime
import matplotlib.pyplot as plt
import seaborn as sb
import shutil
import pprint
pp = pprint.PrettyPrinter(indent=4)
import config
import utils
class UserResults:
def __init__(self, results_list):
self._results = results_list
def results(self):
return self._results
def size(self):
return len(self._results)
class Results:
def __init__(self):
self._results = {}
self._task_results = None
def __setitem__(self, key, value):
setattr(self, key, value)
def __getitem__(self, key):
return getattr(self, key)
def push_user_results(self, team, user, results):
if (not team in self._results):
self._results[team] = {}
self._results[team][user] = results
def results(self, team=None, user = None):
if (user != None):
return self._results[team][user]
elif (team != None):
return self._results[team]
else:
return self._results
def print_results(self, team, user, fr, to):
for r in self._results[team][user].results():
ts = r["timestamp"]
# Does it lie in this task?
if (fr > ts or ts > to):
continue
print(r["timestamp"])
print(r["values"])
print("---")
def __str__(self):
s = "***############################***\n"
s += "***###*** RESULT LOGS ***###***\n"
s += "***############################***\n"
for team, team_dict in self.results().items():
s += f"--- {team} ---\n"
for user, user_results in team_dict.items():
s += f"\t--- {user} ---\n\n"
s += f"\tUser has {user_results.size()} result logs.\n"
s += f"\t--------------------\n\n"
return s