Skip to content

test: compare JAX and Torch exports with the fitted equation - #1397

Merged
MilesCranmer merged 1 commit into
astroautomata:masterfrom
MilesCranmerBot:test/export-vs-predict
Sep 28, 2026
Merged

MilesCranmer merged 1 commit into
astroautomata:masterfrom
MilesCranmerBot:test/export-vs-predict

Conversation

@MilesCranmerBot

Copy link
Copy Markdown
Contributor

Why

test_feature_selection_custom_operators in test_jax.py and test_torch.py compared exported output with the target y. The fit stops at early_stop_condition=1e-5, which can accept an equation whose constants miss y by up to 0.0034 at 3 of 2,000 points. The check uses 3 decimals, so the tests failed on some runners with identical numbers each time, for example on master for #1390 and #1393 and on #1394.

Change

  • JAX: compare the output of the checkpoint-loaded JAX export with the fitted equation, evaluated with sympy.lambdify on the selected features and a NumPy cos_approx.
  • Torch: compare the Torch export with model.predict.

The tests now check export fidelity, which is their purpose, and no longer depend on how close the search gets to y.

Verification

  • Both tests pass locally (Python 3.13, Julia 1.13).
  • Changing the JAX mapping's x**6 / 720 to x**6 / 700 makes the JAX test fail (202 of 2,000 points mismatched), so it still catches a wrong export.

The custom-operator export tests compared exported output with the target data. The search stops at early_stop_condition=1e-5, which can accept constants that miss the target by 0.003 at a few points, so the tests failed on some runners. Compare the exports with the fitted equation instead, which is what the tests check.

Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@MilesCranmer
MilesCranmer merged commit 6954e4f into astroautomata:master Sep 28, 2026
47 checks passed
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