fix: sum PositionsLH penalties instead of doubling the last entry - #700
Merged
Conversation
AnalysisLens.log_likelihood_penalty_from overwrote its accumulator with each entry's penalty and then added the variable to itself, so the analysis subtracted 2x the LAST PositionsLH penalty and silently discarded every earlier entry in positions_likelihood_list. The penalty is now the sum over all entries, matching the documented 1e8 * (max_separation - threshold) contract. Inside-threshold results (converged posteriors, positions-free fits) are unchanged; outside the threshold the fence slope halves from the undocumented 2e8/arcsec to the documented 1e8/arcsec, and multi-plane penalty stacking is corrected. Repins the three tests that encoded the 2x value (the imaging double-plane test asserted the SAME value for one and two penalties -- the 2x-last signature) and adds a regression test that the analysis penalty equals the sum of each entry's own penalty. Docstring aligned to the actual 0.0-array no-penalty return (kept for the JAX path). Closes #699 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Overview
Fixes #699.
AnalysisLens.log_likelihood_penalty_fromoverwrote its accumulator with each entry's penalty and then added the variable to itself (lens.py:171-177), so the analysis subtracted 2x the LASTPositionsLHpenalty and silently discarded every earlier entry inpositions_likelihood_list.Change
1e8 * (max_separation - threshold)contract (autolens/analysis/analysis/lens.py).x = x + y, triviallyxp-safe underjnp).Science impact
Tests
-22048644768.18(exactly half), double-plane-44140499627.75(the true sum, distinct from the old value).-44097289569.2→-22048644815.85).log_likelihood_penalty_from, the two per-plane penalties genuinely differ, and the single-entry case equals the entry's value exactly (no 2x).python -m pytest test_autolens/— 538 passed, 0 failed.Context
CP-1 of the inference-methods programme (planning pass 2026-08-17): every PositionsLH benchmark depends on the penalty matching its documented form. Pending-release: merge is a human act.
🤖 Generated with Claude Code