Skip to content

test(ballistics): assert carry accuracy against committed TrackMan capture - #219

Merged
jewbetcha merged 1 commit into
open-flight:mainfrom
cvrt-jh:test/trackman-carry-regression-budget
Aug 18, 2026
Merged

jewbetcha merged 1 commit into
open-flight:mainfrom
cvrt-jh:test/trackman-carry-regression-budget

Conversation

@cvrt-jh

@cvrt-jh cvrt-jh commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a regression test that replays the committed TrackMan reference capture through the production resolve_launch/simulate path 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.csv is committed and scripts/analysis/validate_ballistics.py can score against it, but nothing in tests/ or CI reads either — so carry accuracy isn't measured on PRs.

The existing carry tests are broad by design: test_ballistics.py:87 asserts 250 <= carry <= 300. That catches gross breakage but not a systematic offset. Current measured error, with the model fed TrackMan's own launch conditions:

club n bias rmse max|d|
7-iron 9 +11.00 11.64 16.25
driver 8 -37.18 38.60 52.29
pitching wedge 7 +11.02 13.56 16.54
OVERALL 24 -5.05 24.52 52.29

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_SATURATION and 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 / _stats from validate_ballistics.py rather 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.

injected overall rmse existing ballistics tests this test
shipped 0.32 / 0.15 24.5 21 pass 5 pass
0.34 / 0.14 21.2 21 pass fails
0.30 / 0.17 30.0 1 fail fails
0.36 / 0.13 19.1 1 fail fails

Row 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:

driver: carry RMSE 49.26 yd exceeds budget 40.0 yd (bias -48.14, max |delta| 63.33, n=8).

Also verified it passes on unmodified main (c9d0cc7) and restored ballistics.py to its committed state afterwards (git diff clean 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, and validate_ballistics imports 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

  • Single feature/fix — one test module, no source changes
  • Automated tests included — the PR is the test
  • Manual testing described — known-answer control above
  • Python tests pass (1326 passed, 8 skipped)
  • Pylint passes (9.70/10, unchanged — no source touched)
  • Ruff passes (ruff check and ruff format --check both clean)
  • UI builds — n/a, no UI changes
  • UI lint passes — n/a, no UI changes
  • Updated docs or CHANGELOG if needed — n/a; the module docstring explains the budget and how to ratchet it
  • No unrelated changes mixed in

…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.

@jewbetcha jewbetcha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants