PyAutoLens: PositionsLH penalty is silently zero when positions contain inf rows (always, when chained from a result) #30
|
Package: PyAutoLens ( What happensThe multiple-image position penalty chained from a previous result does nothing when the positions contain positions_likelihood = source_lp_result.positions_likelihood_from(factor=3.0, minimum_threshold=0.2)for the In that fit, Cause
Reproduced with the real positions and the fitted mass: the max is nan at theta_E 0.369" and at 1.2" alike, while the finite-only max is 2.384" and 0.857". Any user chaining the penalty from a result, which is every SLaM pipeline with a pixelized source, is exposed. Proposed fixDrop non-finite rows in Two alternatives I did not take, which may be worth discussing: Branch: https://github.com/samlange04/PyAutoLens/tree/fix/positions-lh-non-finite, with a regression test (images at +/-1" padded with inf rows; the penalty is 0 at theta_E = 1" and fires at 0.3", red on |
Replies: 2 comments
|
Thanks @samlange04, this was an excellent report: precise root cause (inf → nan → |
Thanks @samlange04, this was an excellent report: precise root cause (inf → nan →
nan > thresholdis False on both the numpy andlax.condpaths), a real-lens reproducer, and a clear explanation of why the nan-safepositions.infomasked it. We confirmed it on the pre-fix code, where padded solver output from a JAX-backed analysis gave a zero penalty even for a wildly wrong Einstein radius. Your PR #765 is now merged into PyAutoLensmainwith your regression tests, and filtering at construction was the right call over a nan-safe max for exactly the reason you gave. It will ship in the next release; until then, anyone running SLaMsource_pix/mass_totalstages on a JAX-backed analysis should …