-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
38 lines (27 loc) · 894 Bytes
/
utils.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
import uuid
from itertools import islice, zip_longest
import numpy
def grouper(iterable, n, max_groups=0, fillvalue=None):
"""Collect data into fixed-length chunks or blocks"""
if max_groups > 0:
iterable = islice(iterable, max_groups * n)
args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue)
def random_string():
return uuid.uuid4().hex[:6].upper().replace("0", "X").replace("O", "Y")
def get_statistics(alist: list):
"""Get summary statistics of a list"""
iat = dict()
if len(alist) > 1:
iat["total"] = sum(alist)
iat["max"] = max(alist)
iat["min"] = min(alist)
iat["mean"] = numpy.mean(alist)
iat["std"] = numpy.sqrt(numpy.var(alist))
else:
iat["total"] = 0
iat["max"] = 0
iat["min"] = 0
iat["mean"] = 0
iat["std"] = 0
return iat