[+] Implement @include-cut

This commit is contained in:
Hykilpikonna
2021-11-25 11:56:20 -05:00
parent 82afe91d11
commit 9ff41d92b0
4 changed files with 25 additions and 10 deletions
+8 -4
View File
@@ -187,16 +187,20 @@ def get_statistics(points: list[float]) -> Stats:
return Stats(statistics.mean(points), statistics.median(points), statistics.stdev(points))
def tabulate_stats(stats: list[Stats]) -> list[list[str]]:
def tabulate_stats(stats: list[Stats], percent: bool = False) -> list[list[str]]:
"""
Create a table structure from statistics for tabulate
:param stats: Statistics
:param percent: Whether the numbers are percentages
:return: Table for tabulate
"""
return [['Mean'] + [f'{s.mean:.2f}' for s in stats],
['Median'] + [f'{s.median:.2f}' for s in stats],
['StdDev'] + [f'{s.stddev:.2f}' for s in stats]]
def num(n: float) -> str:
return f'{n:.2f}' if not percent else f'{n * 100:.1f}%'
return [['Mean'] + [num(s.mean) for s in stats],
['Median'] + [num(s.median) for s in stats],
['StdDev'] + [num(s.stddev) for s in stats]]
def parse_date(iso: str) -> datetime: