diff options
| author | KunoiSayami <[email protected]> | 2023-05-16 12:07:26 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2023-05-16 12:07:26 +0800 |
| commit | b6bcd9a2eb08796e44f317bfcda2a14b6bb311db (patch) | |
| tree | 1743fb105a6d62be9ee331b5204783012f21d10d /analysis0510.py | |
| parent | adc1180f40a904c2773523569033639406da4812 (diff) | |
feat(exp): Enchant expt0510
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'analysis0510.py')
| -rwxr-xr-x | analysis0510.py | 15 |
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) |
