From 60ca05e1e2fb152dbeb69f0558be4d8f42e7b523 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Mon, 17 Oct 2022 19:15:02 -0700 Subject: ref(tools/python): make mypy happy --- tools/seqstat/seqstat.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'tools/seqstat/seqstat.py') diff --git a/tools/seqstat/seqstat.py b/tools/seqstat/seqstat.py index 8450ec8..55b6ecc 100755 --- a/tools/seqstat/seqstat.py +++ b/tools/seqstat/seqstat.py @@ -4,12 +4,6 @@ import argparse ticks = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"] -parser = argparse.ArgumentParser() -parser.add_argument( - "numbers", metavar="N", type=float, nargs="+", help="a number for the accumulator" -) -args = parser.parse_args() - def histogram(sequence): min_val = min(sequence) @@ -22,5 +16,15 @@ def histogram(sequence): return [ticks[int((int(i - min_val) << 8) / scale)] for i in sequence] -h = histogram(args.numbers) -print("".join(h)) +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument( + "numbers", + metavar="N", + type=float, + nargs="+", + help="a number for the accumulator", + ) + args = parser.parse_args() + h = histogram(args.numbers) + print("".join(h)) -- cgit 1.4.1