1

Ajoute la heatmap annuelle des personnages

This commit is contained in:
2025-12-02 01:54:49 +01:00
parent 52dc77878c
commit 21f8b5532c
6 changed files with 194 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
from pathlib import Path
from lib.rebrickable.minifig_characters import aggregate_by_character, write_character_counts
from lib.rebrickable.minifig_characters import aggregate_presence_by_year, write_presence_by_year, load_sets_enriched
def test_aggregate_by_character_counts_unique_figs() -> None:
@@ -35,3 +36,25 @@ def test_write_character_counts_outputs_csv(tmp_path: Path) -> None:
write_character_counts(destination, rows)
assert destination.read_text() == "known_character,minifig_count\nA,2\nB,1\n"
def test_aggregate_presence_by_year_excludes_figurants(tmp_path: Path) -> None:
"""Calcule la présence annuelle en excluant les figurants."""
sets_path = tmp_path / "sets_enriched.csv"
sets_path.write_text(
"set_num,year\n"
"123-1,2020\n"
"124-1,2021\n"
)
minifigs_rows = [
{"set_num": "123-1", "known_character": "Owen Grady", "fig_num": "fig-owen", "part_num": "head-a"},
{"set_num": "124-1", "known_character": "Figurant", "fig_num": "fig-guard", "part_num": "head-b"},
]
sets_years = load_sets_enriched(sets_path)
presence = aggregate_presence_by_year(minifigs_rows, sets_years, excluded_characters=["Figurant"])
assert presence == [
{"known_character": "Owen Grady", "year": "2020", "present": "1"},
{"known_character": "Owen Grady", "year": "2021", "present": "0"},
]