You've already forked etude_lego_jurassic_world
Ajoute les visualisations temporelles des palettes
This commit is contained in:
43
tests/test_colors_timeline_plot.py
Normal file
43
tests/test_colors_timeline_plot.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""Tests des visualisations temporelles des couleurs."""
|
||||
|
||||
import matplotlib
|
||||
from pathlib import Path
|
||||
|
||||
from lib.plots.colors_timeline import plot_colors_heatmap, plot_translucent_share
|
||||
|
||||
|
||||
matplotlib.use("Agg")
|
||||
|
||||
|
||||
def test_plot_translucent_share(tmp_path: Path) -> None:
|
||||
"""Produit un graphique de part de translucides et diversité des couleurs."""
|
||||
timeline_path = tmp_path / "colors_timeline.csv"
|
||||
destination = tmp_path / "figures" / "step14" / "colors_translucent_share.png"
|
||||
timeline_path.write_text(
|
||||
"year,colors_distinct,colors_new,colors_lost,share_translucent,total_quantity,top_colors\n"
|
||||
"2020,2,2,0,0.25,100,Blue (60),Red (40)\n"
|
||||
"2021,3,1,0,0.40,120,Blue (50),Trans-Black (48)\n"
|
||||
)
|
||||
|
||||
plot_translucent_share(timeline_path, destination)
|
||||
|
||||
assert destination.exists()
|
||||
assert destination.stat().st_size > 0
|
||||
|
||||
|
||||
def test_plot_colors_heatmap(tmp_path: Path) -> None:
|
||||
"""Génère une heatmap année × couleur."""
|
||||
matrix_path = tmp_path / "colors_year_color_matrix.csv"
|
||||
destination = tmp_path / "figures" / "step14" / "colors_heatmap.png"
|
||||
matrix_path.write_text(
|
||||
"year,color_rgb,is_translucent,color_name,quantity_total\n"
|
||||
"2020,AAAAAA,false,Gray,5\n"
|
||||
"2020,BBBBBB,true,Trans-Black,2\n"
|
||||
"2021,AAAAAA,false,Gray,3\n"
|
||||
"2021,CCCCCC,false,Blue,4\n"
|
||||
)
|
||||
|
||||
plot_colors_heatmap(matrix_path, destination)
|
||||
|
||||
assert destination.exists()
|
||||
assert destination.stat().st_size > 0
|
||||
Reference in New Issue
Block a user