"""Unit tests for the cosine helper inside journal_search.""" import math from fabledassistant.services.journal_search import _cosine def test_cosine_identical_vectors(): v = [1.0, 2.0, 3.0] assert math.isclose(_cosine(v, v), 1.0, rel_tol=1e-9) def test_cosine_orthogonal_vectors(): a = [1.0, 0.0] b = [0.0, 1.0] assert math.isclose(_cosine(a, b), 0.0, abs_tol=1e-9) def test_cosine_zero_vector_returns_zero(): assert _cosine([0.0, 0.0, 0.0], [1.0, 1.0, 1.0]) == 0.0 def test_cosine_empty_returns_zero(): assert _cosine([], [1.0]) == 0.0