"""セグメンテーションの評価の図(`evaluation/segmentation_figures.py`)の smoke テスト."""
from __future__ import annotations
from pathlib import Path
from tias_judge_model.evaluation.segmentation_figures import (
iou_histogram_filename,
plot_iou_histograms,
)
def test_filename() -> None:
assert iou_histogram_filename("test_cropped") == "seg_iou_hist_test_cropped.png"
def test_plot_creates_png(tmp_path: Path) -> None:
path = tmp_path / "figures" / iou_histogram_filename("s")
plot_iou_histograms({"whole": [0.9, 0.8, 1.2, -0.1], "gt_bbox": [0.95]}, "s", path)
assert path.is_file()
assert path.read_bytes()[:8] == b"\x89PNG\r\n\x1a\n"
def test_plot_with_empty_methods_does_not_fail(tmp_path: Path) -> None:
path = tmp_path / "empty.png"
plot_iou_histograms({"whole": [], "detector": []}, "empty", path)
assert path.is_file()