1

Analyse des têtes dual-face

This commit is contained in:
2025-12-02 17:15:43 +01:00
parent 2050d73105
commit 4ad46b4ede
10 changed files with 627 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
"""Calcule les têtes dual-face des minifigs et leurs agrégats."""
from pathlib import Path
from lib.rebrickable.minifig_head_faces import (
aggregate_by_character,
aggregate_by_set,
aggregate_by_year,
build_head_faces,
write_csv,
)
MINIFIGS_BY_SET_PATH = Path("data/intermediate/minifigs_by_set.csv")
PARTS_CATALOG_PATH = Path("data/raw/parts.csv")
SETS_ENRICHED_PATH = Path("data/intermediate/sets_enriched.csv")
HEAD_FACES_PATH = Path("data/intermediate/minifig_head_faces.csv")
HEAD_FACES_BY_YEAR_PATH = Path("data/intermediate/minifig_head_faces_by_year.csv")
HEAD_FACES_BY_SET_PATH = Path("data/intermediate/minifig_head_faces_by_set.csv")
HEAD_FACES_BY_CHARACTER_PATH = Path("data/intermediate/minifig_head_faces_by_character.csv")
def main() -> None:
"""Construit les listes et agrégats des têtes à visages multiples."""
heads = build_head_faces(MINIFIGS_BY_SET_PATH, PARTS_CATALOG_PATH, SETS_ENRICHED_PATH)
by_year = aggregate_by_year(heads)
by_set = aggregate_by_set(heads)
by_character = aggregate_by_character(heads)
write_csv(
HEAD_FACES_PATH,
heads,
[
"set_num",
"set_id",
"year",
"name",
"in_collection",
"part_num",
"part_name",
"fig_num",
"known_character",
"gender",
"is_dual_face",
],
)
write_csv(
HEAD_FACES_BY_YEAR_PATH,
by_year,
["year", "total_heads", "dual_heads", "share_dual"],
)
write_csv(
HEAD_FACES_BY_SET_PATH,
by_set,
["set_num", "set_id", "name", "year", "in_collection", "total_heads", "dual_heads", "share_dual"],
)
write_csv(
HEAD_FACES_BY_CHARACTER_PATH,
by_character,
["known_character", "gender", "total_heads", "dual_heads", "share_dual"],
)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,28 @@
"""Trace les graphiques liés aux têtes dual-face."""
from pathlib import Path
from lib.plots.minifig_head_faces import (
plot_dual_faces_characters,
plot_dual_faces_timeline,
plot_dual_faces_top_sets,
)
BY_YEAR_PATH = Path("data/intermediate/minifig_head_faces_by_year.csv")
BY_SET_PATH = Path("data/intermediate/minifig_head_faces_by_set.csv")
BY_CHARACTER_PATH = Path("data/intermediate/minifig_head_faces_by_character.csv")
TIMELINE_DESTINATION = Path("figures/step30/minifig_head_faces_timeline.png")
TOP_SETS_DESTINATION = Path("figures/step30/minifig_head_faces_top_sets.png")
CHARACTERS_DESTINATION = Path("figures/step30/minifig_head_faces_characters.png")
def main() -> None:
"""Génère les visuels dual-face."""
plot_dual_faces_timeline(BY_YEAR_PATH, TIMELINE_DESTINATION)
plot_dual_faces_top_sets(BY_SET_PATH, TOP_SETS_DESTINATION)
plot_dual_faces_characters(BY_CHARACTER_PATH, CHARACTERS_DESTINATION)
if __name__ == "__main__":
main()