From b7f2a5c76f3f87ece65efe97ff46fa9f5a7d3cec Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 3 Sep 2026 18:46:20 -0400 Subject: [PATCH] test: re-pin two knife-edge positions_threshold pins after the exact grid transform (PyAutoArray#519) test_autolens/analysis/test_result.py::test__positions_threshold_from and ::test__positions_likelihood_from__mass_centre_radial_distance_min pin a point-solver quantity on an exactly mirror-symmetric configuration (lens centre (0.1, 0) and source (0, 0) both on x = 0). PyAutoArray#519 made transform_grid_2d_to_reference_frame an exact identity at angle 0 (was 8.9e-16 off), so the on-axis deflection is now exactly 0 instead of 6.1e-17, the solver hits an exact tie, and the tie-break puts both images on the same side: positions[1].x flips sign (magnitude bit-identical) and positions_threshold_from() moves 0.0019501455 -> 0.0019534291 (+1.7e-3 relative). Bisected across today's PyAutoArray/PyAutoGalaxy merges: #519's rotation-matrix commit is the sole mover; every other merge is bit-neutral. The new values are the more accurate branch (exact identity, exact on-axis zero); a 1e-15 nudge of the centre flips the pin back, a 1e-6 nudge moves it 86x, so the quantity is a knife-edge, not a physical pin. Re-pinned to the new values with a comment recording the sensitivity and the cause. No library change. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01XhnA4pFN2NycuKc8Ni6s2R --- test_autolens/analysis/test_result.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test_autolens/analysis/test_result.py b/test_autolens/analysis/test_result.py index edea62c0a..c502038bd 100644 --- a/test_autolens/analysis/test_result.py +++ b/test_autolens/analysis/test_result.py @@ -211,9 +211,14 @@ def test__positions_threshold_from(analysis_imaging_7x7): result = res.Result(samples_summary=samples_summary, analysis=analysis_imaging_7x7) - assert result.positions_threshold_from() == pytest.approx(0.0019501455, 1.0e-4) + # Knife-edge pin: the fixture is exactly mirror-symmetric (lens centre and source on + # x = 0), so the point solver's branch is decided by sub-ULP tie-breaking; PyAutoArray#519's + # exact identity transform at angle 0 selected the other branch (positions_threshold + # 0.0019501455 -> 0.0019534291, positions[1].x sign flip, magnitude bit-identical). Values + # are the exact-transform branch; a 1e-15 centre nudge flips them. See PyAutoLens#721. + assert result.positions_threshold_from() == pytest.approx(0.0019534291, 1.0e-4) assert result.positions_threshold_from(factor=5.0) == pytest.approx( - 0.0097507278035, 1.0e-4 + 0.0097671455155, 1.0e-4 ) assert result.positions_threshold_from(minimum_threshold=10.0) == pytest.approx( 10.0, 1.0e-4 @@ -337,11 +342,16 @@ def test__positions_likelihood_from__mass_centre_radial_distance_min( assert isinstance(positions_likelihood, al.PositionsLH) assert len(positions_likelihood.positions) == 2 + # Knife-edge pin: the fixture is exactly mirror-symmetric (lens centre and source on + # x = 0), so the point solver's branch is decided by sub-ULP tie-breaking; PyAutoArray#519's + # exact identity transform at angle 0 selected the other branch (positions_threshold + # 0.0019501455 -> 0.0019534291, positions[1].x sign flip, magnitude bit-identical). Values + # are the exact-transform branch; a 1e-15 centre nudge flips them. See PyAutoLens#721. assert positions_likelihood.positions[0] == pytest.approx( (-1.00097656e00, 5.63818622e-04), 1.0e-4 ) assert positions_likelihood.positions[1] == pytest.approx( - (1.00097656e00, -5.63818622e-04), 1.0e-4 + (1.00097656e00, 5.63818622e-04), 1.0e-4 )