tests/test_similarity.py684 B
import numpy as np
import pytest
from localizer.similarity import azimuth_from, _minmax
@pytest.mark.parametrize(
"lateral,front,expected",
[
(30, True, 30),
(30, False, 150),
(-30, True, -30),
(-30, False, -150),
(0, True, 0),
(90, False, 90),
],
)
def test_azimuth_from_roundtrip(lateral, front, expected):
assert azimuth_from(lateral, front) == expected
def test_minmax_bounds():
x = np.array([2.0, 4.0, 6.0])
n = _minmax(x)
assert n.min() == 0.0 and n.max() == 1.0
assert np.allclose(n, [0.0, 0.5, 1.0])
def test_minmax_constant():
assert np.all(_minmax(np.array([3.0, 3.0, 3.0])) == 0.0)
