summaryrefslogtreecommitdiff
path: root/analysis0510.py
diff options
context:
space:
mode:
Diffstat (limited to 'analysis0510.py')
-rwxr-xr-xanalysis0510.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/analysis0510.py b/analysis0510.py
index c1464ce..59cc65c 100755
--- a/analysis0510.py
+++ b/analysis0510.py
@@ -30,7 +30,7 @@ def get_array_summary(sz: list[float]) -> tuple[str, str]:
return f'{middle:.6f}', f'{avg:.6f}'
-def read(file: str, need_calc: bool = False) -> None:
+def read(file: str, need_calc: bool = False, output_latex: bool = False) -> None:
items = {}
with open(file) as fin:
while s := fin.readline():
@@ -50,7 +50,13 @@ def read(file: str, need_calc: bool = False) -> None:
new_result[key][x].append(element[x])
print(*keys)
for key, value in new_result.items():
- print(key, *list(get_array_summary(value[x]) for x in keys))
+ column = list(get_array_summary(value[x]) for x in keys)
+ if output_latex:
+ column = list(map(str, column))
+ column.insert(0, str(key))
+ print('\\hline\n', ' & '.join(column), '\\\\')
+ else:
+ print(key, *column)
return
print(items)
@@ -58,7 +64,8 @@ def read(file: str, need_calc: bool = False) -> None:
if __name__ == '__main__':
arg_ = argparse.ArgumentParser()
arg_.add_argument("file")
+ arg_.add_argument('--latex', action='store_true')
sub_ = arg_.add_subparsers(title="sub", dest='sub')
- sub_.add_parser('calc')
+ calc_ = sub_.add_parser('calc')
parser_ = arg_.parse_args()
- read(parser_.file, parser_.sub == 'calc')
+ read(parser_.file, parser_.sub == 'calc', parser_.latex)