Use sharper source references in snap and refine

This commit is contained in:
Meta Vens 2026-04-22 13:24:07 +01:00
commit f543f2fa5a
4 changed files with 139 additions and 32 deletions

View file

@ -2,7 +2,7 @@ from __future__ import annotations
import torch
from repixelizer.continuous import _line_pattern_loss
from repixelizer.continuous import _exemplar_colors, _line_pattern_loss
def test_line_pattern_loss_penalizes_wobbling_line() -> None:
@ -19,3 +19,25 @@ def test_line_pattern_loss_penalizes_wobbling_line() -> None:
assert good_loss <= 1e-6
assert bad_loss > good_loss + 0.01
def test_exemplar_colors_selects_an_actual_patch_sample() -> None:
patches = torch.tensor(
[
[
[
[
[0.0, 0.0, 0.0, 1.0],
[0.8, 0.7, 0.1, 1.0],
[0.2, 0.3, 0.9, 1.0],
]
]
]
],
dtype=torch.float32,
)
exemplar = _exemplar_colors(patches)[0, 0, 0]
options = patches[0, 0, 0]
assert any(torch.allclose(exemplar, option) for option in options)