feat(lib): add gaussian_smooth to _postprocess

This commit is contained in:
2026-05-12 01:06:42 +08:00
parent 3c1cf171a7
commit 6d848dc23d
2 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
"""Tests for trajectory post-processing primitives."""
from __future__ import annotations
import numpy as np
from ai_mouse._postprocess import gaussian_smooth
def test_gaussian_smooth_preserves_endpoints() -> None:
x = np.array([1.0, 5.0, 3.0, 8.0, 2.0, 6.0, 4.0])
result = gaussian_smooth(x, sigma=1.0)
assert result[0] == 1.0
assert result[-1] == 4.0
def test_gaussian_smooth_short_input_unchanged() -> None:
x = np.array([1.0, 2.0, 3.0])
result = gaussian_smooth(x, sigma=1.0)
assert np.array_equal(result, x)
def test_gaussian_smooth_constant_unchanged() -> None:
x = np.full(20, 7.5)
result = gaussian_smooth(x, sigma=1.0)
assert np.allclose(result, x, atol=1e-6)