diff options
Diffstat (limited to '')
-rwxr-xr-x | tools/seqstat/seqstat.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/seqstat/seqstat.py b/tools/seqstat/seqstat.py new file mode 100755 index 0000000..8450ec8 --- /dev/null +++ b/tools/seqstat/seqstat.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +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) + max_val = max(sequence) + + scale = (int(max_val - min_val) << 8) / (len(ticks) - 1) + if scale < 1: + scale = 1 + + return [ticks[int((int(i - min_val) << 8) / scale)] for i in sequence] + + +h = histogram(args.numbers) +print("".join(h)) |