Repository navigation
fix: LOSSampler raises on a cosmology that mismatches the colossus name - #874
Merged
Merged
Conversation
cosmology_astropy (deprecated) and LOSSampler(cosmology=...) were silently ignored by the colossus halo mass function and concentration relation, so a WMAP9 caller with the default planck15 colossus name got the Planck15 halo statistics. Both are now checked (H0, Om0) against the colossus cosmology and a mismatch raises a ValueError naming both. Closes #873 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ture (Ok0) Review findings: mass_function_ab_from's hint now names cosmology_name (not cosmology_name_colossus), and a non-flat cosmology no longer passes the check on H0/Om0 alone (LambdaCDM Ode0=0.5 vs planck15 raises, tested). Co-Authored-By: Claude Opus 5.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.
Closes #873
What
After #868 (hmf → colossus),
mass_function_ab_from(cosmology_astropy=...)andLOSSampler(cosmology_astropy=..., cosmology=...)ignored a cosmology that disagrees with the colossus cosmology name. The only signal was aDeprecationWarning, which Python hides from library callers. So a WMAP9 caller with the default"planck15"silently got the Planck15 halo mass function (intercept 8.116 vs 8.108, about 2% in halo counts).The fix is a check, not a mapping. Both arguments are now compared with the colossus cosmology on H0 (rtol 1e-3), Om0 (rtol 1e-2) and curvature Ok0 (atol 1e-3). On a mismatch it raises a
ValueErrorthat names both cosmologies and the argument that fixes it. Om0 is looser because colossus counts massive neutrinos in Om0: astropy Planck15 has 0.3075 and colossus planck15 has 0.3089, a 0.45% gap. WMAP9 differs from planck15 by 2.3% in H0 and 7% in Om0.LOSSamplerruns the check only when it computes halo statistics with colossus. If both coefficient arrays are precomputed, it needs no colossus and runs no check. The workspacelos_halossimulators work this way, so they are unaffected.planck15, WMAP9 withWMAP9, and the defaultLOSSampler().cosmology_astropystays deprecated and still warns.Decision (in the plan, issue #873): the prompt left open whether to map the astropy cosmology to colossus or to raise; the Witness accepts either. I chose to raise. Colossus
fromAstropyneeds sigma8 and ns, which an astropy cosmology does not carry, so a mapping would have to invent them.Overlap with sibling PRs
#870 and #872 change
substructure_util.py. This PR only changeslos.pyandtest_los.py, so the lines do not overlap.Tests
test_autolens/lens/test_los.py: 12 passed (-n 4). New tests:test__mass_function_ab_from__mismatched_cosmology_astropy_raises: WMAP9 with the default raises, naming both cosmologies and thecosmology_namehint; a curved LambdaCDM raises on Ok0; WMAP9 withWMAP9works (B = 8.108).test__los_sampler__mismatched_cosmology_raises:cosmology=FlatLambdaCDM(WMAP9 values)raises, and so doescosmology_astropy=WMAP9. Precomputed coefficients still work.test__los_sampler__matching_cosmology_pair_is_accepted.object().Smoke
Targeted smoke (
pyauto-heart smoke --targeted): no curated script references the change, so it ran the import checkautolens_workspace/scripts/guides/galaxies.py, which passed.Review
The first independent review (leg 3) returned FINDINGS:
mass_function_ab_from.Both are fixed in ebe5a62. The re-review verdict is CLEAN; its only nit is that
match="Ok0"is a loose regex, though the test is still sound because H0 and Om0 match exactly in that case.🤖 Generated with Claude Code