feat: add damp_start (smoothstep lateral damping, no release kink)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
dog
2026-07-09 17:29:41 +08:00
parent c2ed7b3cb9
commit 94c52bd3be
2 changed files with 83 additions and 0 deletions

View File

@@ -182,3 +182,27 @@ def test_soften_forward_no_lower_clip() -> None:
f = np.array([0.0, -0.01, 0.30, 0.70, 1.0])
out = soften_forward(f)
assert out[1] < 0.0
from ai_mouse._postprocess import damp_start
def test_damp_start_dampens_early_lateral() -> None:
lat = np.full(16, 1.0)
out = damp_start(lat, n=4)
assert out[1] < out[2] < out[3] < out[4] < 1.0 # monotone ramp
assert np.all(out[5:] == 1.0) # untouched past n
def test_damp_start_no_release_jump() -> None:
# The weight at i=n must be close to 1 (continuous release):
# smoothstep(4/5) = 0.896, vs the old linear 4/5 = 0.8.
lat = np.full(16, 1.0)
out = damp_start(lat, n=4)
assert out[4] > 0.85
def test_damp_start_short_input_safe() -> None:
lat = np.array([0.0, 0.5, 0.3])
out = damp_start(lat, n=4) # n capped to len//4 = 0 → no-op
assert np.array_equal(out, lat)