|
10 | 10 |
|
11 | 11 | import pytest |
12 | 12 | import torch |
13 | | -from golden_image import compare_to_golden |
| 13 | +from golden_image import RTX_COLOR_PIXEL_L2_THRESHOLD, compare_to_golden |
14 | 14 | from PIL import Image |
15 | 15 | from rendering_runner import _validate_segmentation |
16 | 16 |
|
@@ -59,6 +59,36 @@ def test_difference_fails_and_writes_artifacts(tmp_path: Path, monkeypatch: pyte |
59 | 59 | assert comparison.golden_path is not None and comparison.golden_path.exists() |
60 | 60 |
|
61 | 61 |
|
| 62 | +def test_rtx_color_threshold_ignores_small_shifts_but_not_large_deltas( |
| 63 | + tmp_path: Path, monkeypatch: pytest.MonkeyPatch |
| 64 | +) -> None: |
| 65 | + monkeypatch.delenv("ISAACLAB_UPDATE_GOLDENS", raising=False) |
| 66 | + golden = tmp_path / "golden.png" |
| 67 | + _image((0, 0, 0)).save(golden) |
| 68 | + |
| 69 | + small_shift = compare_to_golden( |
| 70 | + _image((15, 0, 0)), |
| 71 | + golden, |
| 72 | + label="small-shift", |
| 73 | + artifact_dir=tmp_path / "artifacts", |
| 74 | + max_diff_pct=0.0, |
| 75 | + min_ssim=None, |
| 76 | + pixel_l2_threshold=RTX_COLOR_PIXEL_L2_THRESHOLD, |
| 77 | + ) |
| 78 | + large_delta = compare_to_golden( |
| 79 | + _image((30, 0, 0)), |
| 80 | + golden, |
| 81 | + label="large-delta", |
| 82 | + artifact_dir=tmp_path / "artifacts", |
| 83 | + max_diff_pct=0.0, |
| 84 | + min_ssim=None, |
| 85 | + pixel_l2_threshold=RTX_COLOR_PIXEL_L2_THRESHOLD, |
| 86 | + ) |
| 87 | + |
| 88 | + assert small_shift.passed and small_shift.diff_pct == 0.0 |
| 89 | + assert not large_delta.passed and large_delta.diff_pct == 100.0 |
| 90 | + |
| 91 | + |
62 | 92 | def test_missing_baseline_is_bootstrapped_but_fails(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: |
63 | 93 | monkeypatch.delenv("ISAACLAB_UPDATE_GOLDENS", raising=False) |
64 | 94 | golden = tmp_path / "missing.png" |
|
0 commit comments