forked from Ridepad/uwu-logs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logs_top_statistics.py
73 lines (62 loc) · 1.96 KB
/
logs_top_statistics.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
import numpy
from c_player_classes import CLASSES, SPECS_LIST
from h_other import convert_to_html_name
from h_debug import running_time
CLASSES_LIST = list(CLASSES)
IGNORED_SPECS = set([*range(0, 40, 4), 7, 17, 18, 21, 22, 31, 39])
def get_spec_data(spec_index):
spec, icon = SPECS_LIST[spec_index]
_class = CLASSES_LIST[spec_index//4]
return {
"class_name": _class,
"class_html": convert_to_html_name(_class),
"spec_name": spec,
"spec_html": convert_to_html_name(f"{_class} {spec}"),
"icon": icon,
}
SPECS_DATA = [
get_spec_data(spec_index)
for spec_index in range(40)
]
SPECS_DATA_NOT_IGNORED = [
data
for spec_index, data in enumerate(SPECS_DATA)
if spec_index not in IGNORED_SPECS
]
def n_greater_than(data: numpy.ndarray, value: float):
return int((data > value).sum())
def get_percentile(data, percentile):
if percentile == 100:
v = max(data)
n = 1
elif percentile == 0:
v = 0
n = len(data)
else:
v = round(numpy.percentile(data, percentile), 2)
n = n_greater_than(data, v)
return {
"v": v,
"n": n,
}
@running_time
def convert_boss_data(data: dict[int, list[float]]):
BOSS_DATA = {}
for spec_index, values in data.items():
if spec_index in IGNORED_SPECS:
continue
if len(values) < 5:
continue
data_s = numpy.fromiter(values, dtype=numpy.float64)
spec_html = SPECS_DATA[spec_index]["spec_html"]
BOSS_DATA[spec_html] = {
"top100": get_percentile(data_s, 100),
"top99": get_percentile(data_s, 99),
"top95": get_percentile(data_s, 95),
"top90": get_percentile(data_s, 90),
"top75": get_percentile(data_s, 75),
"top50": get_percentile(data_s, 50),
"top10": get_percentile(data_s, 10),
"all": get_percentile(data_s, 0),
}
return BOSS_DATA