Repository navigation
Closed
Description
Overview
After #868 (hmf → colossus), LOSSampler and mass_function_ab_from accept cosmology_astropy but ignore it, emitting only a DeprecationWarning that Python hides from non-__main__ callers. A caller passing e.g. WMAP9 with the default cosmology_name_colossus="planck15" silently gets the Planck15 mass function (~2% in halo counts). LOSSampler(cosmology=...) is likewise never checked against the colossus cosmology name.
Plan
- Add a helper that compares a supplied cosmology (astropy or autogalaxy
LensingCosmology) with the colossus cosmology by H0 and Om0, and raises aValueErrornaming both when they disagree. mass_function_ab_from(cosmology_astropy=...)runs the check (the argument is still deprecated, but no longer silently ignored).LOSSamplerruns the same check oncosmologyandcosmology_astropyagainstcosmology_name_colossus, at sampling time and only when colossus is actually used (precomputed coefficients still need no colossus).- Matching pairs (e.g. Planck15 /
planck15, WMAP9 /WMAP9) work unchanged. - Witness tests (skip without colossus).
- effective level: supervised; merge mode: auto-merge on green if the Witness passes after a merge slot
Detailed plan
Work Classification: Library (PyAutoLens only)
Branch: feature/lossampler-cosmology-mismatch
Worktree root: ~/Code/PyAutoLabs-wt/lossampler-cosmology-mismatch/
autolens/lens/los.py: new_check_cosmology_matches_colossus(cosmology, col_cosmo, cosmology_name, argument); H0 read viagetattr(H0, "value", H0)(astropy Quantity); tolerances rel 1e-3 on H0, 1e-2 on Om0 (colossus Om0 includes massive neutrinos: Planck15 astropy 0.3075 vs colossus 0.3089, 0.45%). WMAP9 vs planck15 differs 2.3% in H0 and 7% in Om0.mass_function_ab_from: after setting the colossus cosmology, checkcosmology_astropyif given. Deprecation warning text updated ("checked, not used").LOSSampler._sample_population: when either coefficient array is None, set the colossus cosmology and checkself.cosmologyandself.cosmology_astropy.- Tests in
test_autolens/lens/test_los.py: WMAP9+planck15 raises naming both (function + sampler, viacosmology_astropyand viacosmology=FlatLambdaCDM(H0=69.32, Om0=0.2865)); matching pairs pass; existing deprecation test passes a real Planck15.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Jammy2211 commentedon Nov 20, 2026
Shipped
Merged 2026-11-20 via the human's
/prm(shift 2026-11-19-pm2): #874mass_function_ab_from(cosmology_astropy=...)andLOSSampler(cosmology=..., cosmology_astropy=...)now raise a ValueError naming both cosmologies when the supplied astropy cosmology disagrees with the colossus name (H0 rtol 1e-3, Om0 rtol 1e-2, Ok0 atol 1e-3). Matching pairs and precomputed coefficients are unchanged.Witness: on main, WMAP9 + default planck15 silently returned the Planck15 fit (B = 8.116); now it raises, with a hint to pass
cosmology_name='WMAP9'.test_los.py12 passed; targeted smoke import check PASS; independent Opus 5.5 review FINDINGS(2) fixed, then CLEAN.