diff options
| author | Franck Cuny <franck@fcuny.net> | 2022-10-15 12:32:28 -0700 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2022-10-15 12:32:28 -0700 |
| commit | ce39b5fd65a91e241b2edbb9fd6a9a12967a064d (patch) | |
| tree | bd0ec3519ac3a41c55193023dc3f3bb2705114a1 /tools/seqstat/seqstat.py | |
| parent | ci: update the flake once a week (diff) | |
| download | infra-ce39b5fd65a91e241b2edbb9fd6a9a12967a064d.tar.gz | |
ref(seqstat): rewrite from go to python
This is a simple script, there's no benefit in having this in go. Having
it Python makes it easier to extend with panda or other libraries in the
future if I need more statistics too.
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)) |
