From fd79a989954236954c5d0dee7f2dec4ed1306926 Mon Sep 17 00:00:00 2001 From: =?utf8?q?tom=C3=A1s=20zerolo?= Date: Sun, 20 Nov 2022 13:44:05 +0100 Subject: [PATCH] start --- filesizes.py | 32 ++++++++++++++++++++++++++++++++ notes | 2 ++ weights.py | 19 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100755 filesizes.py create mode 100644 notes create mode 100755 weights.py diff --git a/filesizes.py b/filesizes.py new file mode 100755 index 0000000..893432e --- /dev/null +++ b/filesizes.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +# File sizes: histogram of file sizes + +import sys +import os +from pathlib import Path +import matplotlib.pyplot as plot + +if len(sys.argv) != 2: + print(f"Usage: {sys.argv[0]} \n") + exit(1) + +def collectdir(direc): + sizes = [] + if not direc.is_dir(): + print(f"{direc} is not a directory!") + exit(1) + + for it in direc.iterdir(): + if os.access(it, os.R_OK): # ignore otherwise + if it.is_file(): + sizes += [it.stat().st_size] + elif it.is_dir(): + sizes += collectdir(it) + + return sizes + +plot.hist(collectdir(Path(sys.argv[1])), 100) +plot.show() + +# plot.hist(weights, 8, facecolor='blue') +# plot.show() diff --git a/notes b/notes new file mode 100644 index 0000000..f4f9c36 --- /dev/null +++ b/notes @@ -0,0 +1,2 @@ +# -*- mode: org -*- +#+title: histograms diff --git a/weights.py b/weights.py new file mode 100755 index 0000000..04a9180 --- /dev/null +++ b/weights.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 +# Small extract from http://wiki.stat.ucla.edu/socr/index.php/SOCR_Data_MLB_HeightsWeights +# (body weights of baseball players) +# (only the weights in pounds, only the first 80) + +import matplotlib.pyplot as plot + +weights=[ + 180, 215, 210, 210, 188, 176, 209, 200, 231, 180, + 188, 180, 185, 160, 180, 185, 197, 189, 185, 219, + 230, 205, 230, 195, 180, 192, 225, 203, 195, 182, + 188, 200, 180, 200, 200, 245, 240, 215, 185, 175, + 199, 200, 215, 200, 205, 206, 186, 188, 220, 210, + 195, 244, 195, 200, 200, 212, 224, 210, 205, 220, + 195, 200, 260, 228, 270, 200, 210, 190, 220, 180, + 205, 210, 220, 211, 200, 180, 190, 170, 230, 155] + +plot.hist(weights, 8, facecolor='blue') +plot.show() -- 2.30.2