Skip to content

test: Richardson-step regression asserts; theta_for_beta tol 1e-12 (PyAutoGalaxy#591) - #717

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/lenscalc-adaptive-hessian-step
Aug 29, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/lenscalc-adaptive-hessian-step

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Test-only follow-up to PyAutoGalaxy#593 (adaptive Richardson step in LensCalc's NumPy Hessian, fixing PyAutoGalaxy#591). Two changes:

  • test_autolens/lens/test_multi_plane_cross_validation.py — the strict xfail that pinned the defect on the PyAutoLens#480 fixture now XPASSes; it is converted to a positive regression assertion (renamed test__bug_480_configuration__numpy_richardson_hessian_agrees_at_the_last_plane): the NumPy Hessian magnification at the last plane matches the ray-traced Jacobian at rtol 1e-3 (agreement measured at 3.4e-4, the stored reference's own precision), with no UserWarning.
  • test_autolens/point/fit/test_solved.py — theta_for_beta's scipy.optimize.root(..., tol=1e-14) relaxed to 1e-12. With the more accurate Hessian, scipy reported status 3 ("xtol too small") at a residual of ~1e-16 — a termination-path artefact, not a physics change; all three physics assertions in TestTensorVsScalarWeighting hold either way. Comment added at the call site.

API Changes

None — tests only.
See full details below.

Test Plan

Full API Changes (for automation & release notes)

Removed

  • none

Added

  • none (tests only)

Migration

  • none

Refs PyAutoGalaxy#591, PyAutoGalaxy#593.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WzKP1RJKhPrtFmsHSm6EEA

Jammy2211 and others added 2 commits August 29, 2026 15:52
`test__bug_480_configuration__numpy_richardson_hessian_step_is_too_coarse` was
a strict xfail pinning the defect: `LensCalc`'s NumPy Hessian at the last plane
of the PyAutoLens#480 configuration returned
[-0.00694, -0.00221, 0.00139, 0.00246] against the
[0.04508, 0.01099, -0.08602, -0.01118] that exact JAX autodiff and the
ray-traced Jacobian agree on.

PyAutoGalaxy#591 made the Richardson step adapt per point, so the xfail now
XPASSes. It becomes a positive assertion against the ray-traced Jacobian at the
same rtol=1e-3 used everywhere else in this module - the tolerance was not
widened when the test recorded a disagreement and is not tightened now that it
records an agreement. Renamed to
`..._numpy_richardson_hessian_agrees_at_the_last_plane`, since the old name
states a claim that is no longer true.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzKP1RJKhPrtFmsHSm6EEA
…essian (PyAutoGalaxy#591)

`TestTensorVsScalarWeighting`'s ground-truth ray-trace solved
`beta_of_theta(theta) == target_beta` with `scipy.optimize.root(method="hybr",
tol=1e-14)` and asserted `solution.success`. The jacobian precision tensor's
off-diagonal is numerically zero there (1.08e-06 against diagonals 2.04e+06
and 1.00e+04), so the low-precision eigenvector is
`(5.3e-13, -1)`; PyAutoGalaxy#591's more accurate Hessian moves those last
bits, which moves `target_beta` and with it scipy's termination path. The
solver then returns status 3, "xtol too small, no further improvement", at a
residual of 8.4e-17 - the root is found to machine precision, only the flag
differs. The test's three physics assertions (tensor ordering, scalar
ordering, and the true image-plane distances 0.010000 < 0.013505) hold either
way.

1e-12 is still far tighter than the 1e-3 scale the test discriminates on.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzKP1RJKhPrtFmsHSm6EEA
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Aug 29, 2026
@Jammy2211
Jammy2211 merged commit 9e1fb96 into main Aug 29, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/lenscalc-adaptive-hessian-step branch August 29, 2026 20:20
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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.

1 participant