refactor: move eval/ and data_adapters/ to tools/
This commit is contained in:
@@ -8,7 +8,7 @@ import pytest
|
||||
class TestKinematics:
|
||||
def test_compute_speed_constant_velocity(self):
|
||||
"""Constant-velocity trajectory has constant speed."""
|
||||
from ai_mouse.eval.metrics import compute_speed
|
||||
from tools.eval.metrics import compute_speed
|
||||
# 10 points, moving 10 px in 100 ms each step → speed = 0.1 px/ms
|
||||
xs = np.arange(0, 100, 10, dtype=float)
|
||||
ys = np.zeros(10, dtype=float)
|
||||
@@ -20,7 +20,7 @@ class TestKinematics:
|
||||
|
||||
def test_compute_speed_handles_zero_dt(self):
|
||||
"""Adjacent points with same timestamp must not produce NaN/inf."""
|
||||
from ai_mouse.eval.metrics import compute_speed
|
||||
from tools.eval.metrics import compute_speed
|
||||
xs = np.array([0.0, 10.0, 20.0])
|
||||
ys = np.array([0.0, 0.0, 0.0])
|
||||
ts = np.array([0.0, 0.0, 100.0]) # zero dt between [0] and [1]
|
||||
@@ -29,7 +29,7 @@ class TestKinematics:
|
||||
|
||||
def test_compute_acceleration(self):
|
||||
"""Linearly increasing speed → constant acceleration."""
|
||||
from ai_mouse.eval.metrics import compute_acceleration
|
||||
from tools.eval.metrics import compute_acceleration
|
||||
# speeds: 0.1, 0.2, 0.3, 0.4 over dt = 100 ms each → a = 0.001 px/ms²
|
||||
speeds = np.array([0.1, 0.2, 0.3, 0.4])
|
||||
ts = np.array([100.0, 200.0, 300.0, 400.0])
|
||||
@@ -37,7 +37,7 @@ class TestKinematics:
|
||||
np.testing.assert_allclose(a, 0.001, rtol=1e-4)
|
||||
|
||||
def test_compute_jerk(self):
|
||||
from ai_mouse.eval.metrics import compute_jerk
|
||||
from tools.eval.metrics import compute_jerk
|
||||
# accelerations: 0.001, 0.002, 0.003 over dt = 100 ms → j = 0.00001
|
||||
accels = np.array([0.001, 0.002, 0.003])
|
||||
ts = np.array([200.0, 300.0, 400.0])
|
||||
@@ -47,7 +47,7 @@ class TestKinematics:
|
||||
|
||||
class TestStatsSummary:
|
||||
def test_compute_stats_returns_expected_keys(self):
|
||||
from ai_mouse.eval.metrics import compute_stats
|
||||
from tools.eval.metrics import compute_stats
|
||||
x = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
|
||||
s = compute_stats(x)
|
||||
assert "mean" in s
|
||||
@@ -59,7 +59,7 @@ class TestStatsSummary:
|
||||
assert "p95" in s
|
||||
|
||||
def test_cv_for_constant_is_zero(self):
|
||||
from ai_mouse.eval.metrics import compute_stats
|
||||
from tools.eval.metrics import compute_stats
|
||||
x = np.full(10, 3.0)
|
||||
s = compute_stats(x)
|
||||
assert s["cv"] == 0.0
|
||||
@@ -68,7 +68,7 @@ class TestStatsSummary:
|
||||
class TestFftSpectrum:
|
||||
def test_finds_dominant_frequency(self):
|
||||
"""A pure 8 Hz signal should have its peak near 8 Hz."""
|
||||
from ai_mouse.eval.metrics import fft_spectrum
|
||||
from tools.eval.metrics import fft_spectrum
|
||||
# Sample at 100 Hz for 1 second
|
||||
sample_rate_hz = 100.0
|
||||
ts_ms = np.arange(0, 1000, 1000 / sample_rate_hz)
|
||||
@@ -78,7 +78,7 @@ class TestFftSpectrum:
|
||||
assert abs(peak_freq - 8.0) < 1.0 # within 1 Hz
|
||||
|
||||
def test_returns_only_positive_frequencies(self):
|
||||
from ai_mouse.eval.metrics import fft_spectrum
|
||||
from tools.eval.metrics import fft_spectrum
|
||||
signal = np.random.randn(64)
|
||||
freqs, mags = fft_spectrum(signal, 50.0)
|
||||
assert (freqs >= 0).all()
|
||||
@@ -88,7 +88,7 @@ class TestFftSpectrum:
|
||||
class TestKlDivergence:
|
||||
def test_identical_distributions_zero_kl(self):
|
||||
"""KL(p, p) ≈ 0."""
|
||||
from ai_mouse.eval.metrics import kl_divergence_histograms
|
||||
from tools.eval.metrics import kl_divergence_histograms
|
||||
rng = np.random.default_rng(42)
|
||||
x = rng.normal(0, 1, 5000)
|
||||
y = rng.normal(0, 1, 5000)
|
||||
@@ -97,7 +97,7 @@ class TestKlDivergence:
|
||||
|
||||
def test_different_distributions_positive_kl(self):
|
||||
"""Different means → positive KL."""
|
||||
from ai_mouse.eval.metrics import kl_divergence_histograms
|
||||
from tools.eval.metrics import kl_divergence_histograms
|
||||
rng = np.random.default_rng(42)
|
||||
x = rng.normal(0, 1, 5000)
|
||||
y = rng.normal(3, 1, 5000)
|
||||
@@ -106,7 +106,7 @@ class TestKlDivergence:
|
||||
|
||||
def test_handles_disjoint_supports(self):
|
||||
"""No NaN even when histograms have non-overlapping bins."""
|
||||
from ai_mouse.eval.metrics import kl_divergence_histograms
|
||||
from tools.eval.metrics import kl_divergence_histograms
|
||||
x = np.array([1.0, 1.1, 1.2, 1.3, 1.4])
|
||||
y = np.array([10.0, 10.1, 10.2, 10.3, 10.4])
|
||||
kl = kl_divergence_histograms(x, y, bins=10)
|
||||
@@ -116,7 +116,7 @@ class TestKlDivergence:
|
||||
class TestReportGeneration:
|
||||
def test_generates_report_md(self, tmp_path):
|
||||
"""Smoke test: build_report writes an MD file with all expected sections."""
|
||||
from ai_mouse.eval.report import build_report
|
||||
from tools.eval.report import build_report
|
||||
|
||||
# Synthetic generated traces (3 traces, 50 points each)
|
||||
rng = np.random.default_rng(0)
|
||||
|
||||
Reference in New Issue
Block a user