Repository navigation
test(ballistics): assert carry accuracy against committed TrackMan capture - #219
Merged
jewbetcha merged 1 commit intoAug 18, 2026
Merged
Conversation
…pture The repo ships a paired TrackMan reference capture in session_logs/ and a validator in scripts/analysis/validate_ballistics.py, but nothing in tests/ or CI reads either, so carry accuracy is unmeasured on PRs. The existing carry tests use broad ranges (test_ballistics.py:87 asserts 250-300 yd), which catch gross breakage but not a systematic offset. Replay the committed capture through the production resolve_launch/simulate path and assert per-club RMSE against a budget. Budgets are seeded at the currently measured error rather than at zero, so new error fails immediately while the existing offset stays payable down deliberately. Reuses load_trackman/validate_tm_inputs/_stats from the validator so the test and the manual tool cannot drift apart, and skips cleanly when the capture file is absent.
7 of 8 tasks
8 of 10 tasks
8 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a regression test that replays the committed TrackMan reference capture through the production
resolve_launch/simulatepath and asserts per-club carry RMSE against a budget.One new file,
tests/test_ballistics_trackman_regression.py. No source changes.Addresses #218.
Why was this required?
session_logs/OpenFlight-Test.Normalized.csvis committed andscripts/analysis/validate_ballistics.pycan score against it, but nothing intests/or CI reads either — so carry accuracy isn't measured on PRs.The existing carry tests are broad by design:
test_ballistics.py:87asserts250 <= carry <= 300. That catches gross breakage but not a systematic offset. Current measured error, with the model fed TrackMan's own launch conditions:Budgets are seeded at these values rather than at zero, so this blocks new error today without blocking anyone on the existing offset. Ratchet them down as the model improves.
A side benefit: this makes an aero-constant fix defensible. Right now there's no way to change
CL_SATURATIONand demonstrate the change helped.Automated tests
5 tests: overall RMSE budget, per-club RMSE budget (3 clubs, parametrised), and a fixture-size pin so budget drift can't hide behind a changed capture file.
Reuses
load_trackman/validate_tm_inputs/_statsfromvalidate_ballistics.pyrather than reimplementing them, so the test and the manual tool can't disagree about what the reference data means. Skips cleanly if the capture is absent.Manual (human) testing
Ran a known-answer control: injected coefficient changes and compared what each suite catches.
0.32 / 0.150.34 / 0.140.30 / 0.170.36 / 0.13Row 2 is the interesting one — it passes every existing ballistics test. This catches it because overall RMSE improves (24.5→21.2) while 7-iron (11.6→16.0) and pitching wedge (13.6→15.5) both regress. A single aggregate number would wave that through.
Confirmed the failure output is actionable:
Also verified it passes on unmodified
main(c9d0cc7) and restoredballistics.pyto its committed state afterwards (git diffclean apart from the new file).One caveat I can't close myself: I only have Python 3.13/3.14 locally, so I haven't run this on the 3.10-3.12 matrix CI uses. The module is stdlib-only with
from __future__ import annotations, andvalidate_ballisticsimports nothing beyond stdlib at module scope (matplotlib is imported lazily inside a function this test never calls), so I don't expect trouble — but CI will confirm.Checklist
1326 passed, 8 skipped)ruff checkandruff format --checkboth clean)