"""Render smoke test — skipped where plotstyle / LaTeX is unavailable.""" from __future__ import annotations from pathlib import Path import pytest pytest.importorskip("plotstyle") from giant.analysis.reduced import Reduced # noqa: E402 def _try_render(reduced: list[Reduced], out: Path): from giant.analysis.render import render_all for r in reduced: r.save(out / "reduced" / f"{r.id}.json") return render_all(out / "reduced", out / "plots") def test_render_one_of_each_kind(tmp_path: Path): reduced = [ Reduced( "m", "marginals", "overlay_hist", "Overlay", "x", { "edges": [0, 1, 2, 3], "rollout": [1, 2, 3], "reference": [3, 2, 1], "log_y": False, }, ), Reduced( "g", "marginals", "grouped_hist", "Grouped", "x", { "edges": [0, 1, 2], "groups": {"a": {"rollout": [1, 2], "reference": [2, 1]}}, "log_y": False, }, ), Reduced( "p", "shower", "profile", "Profile", "depth", { "edges": [0, 1, 2], "rollout_mean": [1, 2], "rollout_std": [0.1, 0.2], "reference_mean": [1.1, 1.9], "reference_std": [0.1, 0.1], "ylabel": "e", }, ), Reduced( "b", "species", "bar", "Bar", "species", { "labels": ["e-", "gamma"], "rollout": [0.6, 0.4], "reference": [0.5, 0.5], "ylabel": "frac", }, ), Reduced( "s", "species", "single_hist", "Single", "x", {"edges": [0, 1, 2], "rollout": [5, 1], "log_y": True}, ), ] try: pdfs = _try_render(reduced, tmp_path) except RuntimeError as e: # LaTeX missing at render time pytest.skip(f"LaTeX rendering unavailable: {e}") assert len(pdfs) == len(reduced) assert all(p.exists() for p in pdfs) assert (tmp_path / "plots" / "metadata.yaml").exists()