From e8cd0d346d9741efb30ba063904c3aed4411c97a Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Wed, 3 Dec 2025 21:04:11 +0100 Subject: [PATCH] Filtrer les sets sans minifigs dans le graphique step21 --- lib/plots/minifig_counts.py | 4 +++- tests/test_minifig_counts_plot.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/plots/minifig_counts.py b/lib/plots/minifig_counts.py index d9355aa..1fcb8f3 100644 --- a/lib/plots/minifig_counts.py +++ b/lib/plots/minifig_counts.py @@ -16,7 +16,9 @@ def load_counts(path: Path) -> List[dict]: def plot_minifigs_per_set(counts_path: Path, destination_path: Path) -> None: """Trace un diagramme en barres du nombre de minifigs par set (thèmes filtrés).""" - rows = load_counts(counts_path) + rows = [row for row in load_counts(counts_path) if int(row["minifig_count"]) > 0] + if not rows: + return labels = [f"{row['set_num']} - {row['name']}" for row in rows] values = [int(row["minifig_count"]) for row in rows] positions = list(range(len(rows))) diff --git a/tests/test_minifig_counts_plot.py b/tests/test_minifig_counts_plot.py index c6e82e1..166a667 100644 --- a/tests/test_minifig_counts_plot.py +++ b/tests/test_minifig_counts_plot.py @@ -17,6 +17,7 @@ def test_plot_minifigs_per_set_outputs_image(tmp_path: Path) -> None: "set_num,set_id,name,year,minifig_count\n" "123-1,123,Set A,2020,2\n" "124-1,124,Set B,2021,1\n" + "125-1,125,Set C,2021,0\n" ) plot_minifigs_per_set(counts_path, destination_path)