Repository navigation
Conversation
|
Guideline / #895 review of Scientific trajectory metrics belong with biomechanics; the custom_measures hook already lets DTW compose without a dependency on #867. No justified stack edge between these PRs. New Frechet/rollout comparison APIs need human design/implementation approval and documented distance units and resampling semantics; the added numerical tests are useful. No concrete runtime blocker established by this static review. Checks: current diff/source, discussions and check-run metadata inspected; no fresh local runtime tests run. Current-head GitHub checks: CPU, mjlab, docs and pre-commit passed. Human design/implementation approval remains required; this review is not an auto-approval. |
|
Automated cross-repo audit (compatibility, composition, reuse) of
Nothing here blocks merging on its own; the items are for the next revision. Generated by Claude Code |
a3cded5 to
3f9afb0
Compare
…etrics Add DTWAlignment, dtw_alignment and dtw_distance for multidimensional trajectories with an optional Sakoe-Chiba band (Sakoe & Chiba, 1978; Berndt & Clifford, 1994). The Euclidean cost matrix is computed exactly in NumPy and passed to tslearn.metrics.dtw_path_from_metric (precomputed), so identical samples cost exactly zero. tslearn is imported lazily through the optional analysis extra introduced for the Discrete Frechet metrics. Costs match the previous hand-written dynamic program exactly on 300 random unconstrained pairs and on equal-length banded pairs (radius 0, 2, 5); about 12x faster on 500x600 steps. For unequal lengths the band now follows tslearn's Sakoe-Chiba mask. Verified with tslearn 0.7.0 and 0.10.0. Stacked on feat/kinematic-frechet (MyoHub#886).
|
@copilot resolve the merge conflicts in this pull request |
Merged the current |
Replace the hand-rolled Eiter & Mannila recurrence and coupling backtrack with tslearn.metrics.frechet / frechet_path, and the linear resampler with np.interp. tslearn is imported lazily from a new optional `analysis` extra (added to `dev` and the CI install), so `import myosuite` and the module itself load neither tslearn nor numba. tslearn uses the same recurrence and the same diagonal-first tie-breaking: distances and couplings match the previous implementation exactly on 300 random pairs, including tied cases. tslearn>=0.7 passes the test suite.
3a40a76 to
1b9e184
Compare
…etrics Add DTWAlignment, dtw_alignment and dtw_distance for multidimensional trajectories with an optional Sakoe-Chiba band (Sakoe & Chiba, 1978; Berndt & Clifford, 1994). The Euclidean cost matrix is computed exactly in NumPy and passed to tslearn.metrics.dtw_path_from_metric (precomputed), so identical samples cost exactly zero. tslearn is imported lazily through the optional analysis extra introduced for the Discrete Frechet metrics. Costs match the previous hand-written dynamic program exactly on 300 random unconstrained pairs and on equal-length banded pairs (radius 0, 2, 5); about 12x faster on 500x600 steps. For unequal lengths the band now follows tslearn's Sakoe-Chiba mask. Verified with tslearn 0.7.0 and 0.10.0. Stacked on feat/kinematic-frechet (MyoHub#886).
Category: new scientific analysis feature + optional dependency extra (
analysis = ["tslearn>=0.7"]; Milestone3.2, base of #980; requires maintainer approval).Summary
myosuite.biomechanics.kinematic_metrics): AddsFrechetAlignment,discrete_frechet_alignment, anddiscrete_frechet_distance(Eiter & Mannila 1994) for 1D(T,)and multidimensional(T, D)trajectories of equal or unequal length. Distances preserve the caller's input coordinate units (e.g., meters forsite_xpos, radians for joint angles;zero_start=Truesubtracts each trajectory's initial sample before comparison).EntityTrajectoryMetricsandcompare_rollout_trajectories, reporting per-quantity synchronous Euclidean error, normalized[0, 1]timeline-resampled Euclidean error (np.interpover normalized progressuin[0, 1]), Discrete Fréchet distance, and optionalcustom_measurescallables (such as feat(biomechanics): add Dynamic Time Warping trajectory alignment to kinematic_metrics #980's DTW).analysisextra (pyproject.toml,uv.lock,.github/workflows/python-app.yml): Addsanalysis = ["tslearn>=0.7"](included indevand CI).tslearnis imported lazily inside the Fréchet call path soimport myosuiteandimport myosuite.biomechanics.kinematic_metricsnever loadtslearnornumba; calling Fréchet without the extra raises an actionableImportErrornamingmyosuite[analysis].Ownership & Reuse (
REVIEW.md)MyoSuite(myosuite/biomechanics/kinematic_metrics.py— trajectory and rollout evaluation metrics; zero anatomical or physical model transforms, so nothing belongs inmyo_sim).tslearn.metrics.frechet/tslearn.metrics.frechet_path(BSD-2-Clause) and timeline interpolation tonumpy.interp, placed alongside existing smoothness/Fitts metrics inmyosuite/biomechanics/kinematic_metrics.pyand registered indocs/source/developer/library-usage.mdandtest_biomechanics_layout.py. (similaritymeasures.frechet_distwas evaluated and rejected because it uses a pure-Python loop and returns no alignment path.)77lines removed in1b9e1841) withtslearn.metrics.frechet_path(verified bit-identical on 300 random pairs including rounded tie cases;6.8 msvs10.6 mson500x700x39).Compatibility & Checks
pip install myosuitedependencies, registered environments, and checkpoints are unchanged (numbacapsnumpy<2.6, which is whytslearn>=0.7lives in the optionalanalysisextra;numba/llvmlite/statsmodelsshipcp310–cp315wheels). First-call JIT compilation per process is ~6 s.dev0b8631a5at1b9e1841):pre-commit run --from-ref origin/dev --to-ref HEAD: passed.pytest myosuite/tests/test_kinematic_frechet.py myosuite/tests/test_kinematic_metrics.py myosuite/tests/test_biomechanics_layout.py myosuite/tests/test_import_footprint.py -v(Python 3.13.18,tslearn0.8+/0.10, plus verified earlier ontslearn0.7.0): passed.AGENTS.mdcore verification suites (test_model_builder.py,test_terms_cpu.py,test_fragment_compat.py,test_parity.py,test_registry.py):350 passed, 3 skipped.dev/release CI).