about summary refs log tree commit diff
path: root/packages/seqstat/seqstat.py
blob: 55b6ecc8434b80e988b7efaa7c3e2624b45b25f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3

import argparse

ticks = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]


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]


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))