feat(generator): add 5-point gaussian smoothing on lateral
This commit is contained in:
@@ -124,3 +124,35 @@ class TestPostProcessing:
|
||||
if len(values) > 1:
|
||||
return # at least one position has variation — pass
|
||||
pytest.fail("All 5 Δt sequences are identical at every position — diversity collapsed")
|
||||
|
||||
|
||||
class TestGaussianSmooth:
|
||||
def test_endpoints_preserved(self):
|
||||
from ai_mouse.generator import _gaussian_smooth
|
||||
x = np.array([1.0, 5.0, 3.0, 7.0, 2.0], dtype=np.float64)
|
||||
smoothed = _gaussian_smooth(x, sigma=1.0)
|
||||
assert smoothed[0] == 1.0
|
||||
assert smoothed[-1] == 2.0
|
||||
|
||||
def test_smooths_high_frequency(self):
|
||||
"""A high-frequency square wave should have reduced amplitude after smoothing."""
|
||||
from ai_mouse.generator import _gaussian_smooth
|
||||
x = np.array([0, 1, 0, 1, 0, 1, 0, 1, 0, 1], dtype=np.float64)
|
||||
smoothed = _gaussian_smooth(x, sigma=1.0)
|
||||
# Interior amplitude should be reduced
|
||||
interior_orig = x[2:-2]
|
||||
interior_smooth = smoothed[2:-2]
|
||||
assert interior_smooth.std() < interior_orig.std()
|
||||
|
||||
def test_constant_signal_unchanged(self):
|
||||
from ai_mouse.generator import _gaussian_smooth
|
||||
x = np.full(20, 0.5, dtype=np.float64)
|
||||
smoothed = _gaussian_smooth(x, sigma=1.0)
|
||||
np.testing.assert_allclose(smoothed, x, rtol=1e-6)
|
||||
|
||||
def test_short_array_returns_unchanged(self):
|
||||
"""Arrays shorter than the kernel are returned unchanged."""
|
||||
from ai_mouse.generator import _gaussian_smooth
|
||||
x = np.array([1.0, 2.0, 3.0], dtype=np.float64)
|
||||
smoothed = _gaussian_smooth(x, sigma=1.0)
|
||||
np.testing.assert_allclose(smoothed, x, rtol=1e-6)
|
||||
|
||||
Reference in New Issue
Block a user