Skip to content

feat(cosmo): consolidate sp_validation cosmology theory-curve machinery into cs_util.cosmo#76

Open
cailmdaley wants to merge 1 commit into
developfrom
feat/cosmo-from-sp_validation
Open

feat(cosmo): consolidate sp_validation cosmology theory-curve machinery into cs_util.cosmo#76
cailmdaley wants to merge 1 commit into
developfrom
feat/cosmo-from-sp_validation

Conversation

@cailmdaley

@cailmdaley cailmdaley commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Closes #75 (PR 1 of 2 — the cs_util side).

Moves the cosmology theory-curve machinery from sp_validation.cosmology into cs_util.cosmo, so cs_util is the single home for the collaboration's cosmology primitives (per a conversation with Martin).

What moves in

  • PLANCK18 fiducial-cosmology dict
  • get_cosmo — flexible Planck18-default cosmology builder (individual / CCL / CAMB / CosmoCov parameter formats)
  • get_theo_c_ell, c_ell_to_xi, get_theo_xi — angular power spectra and shear correlation functions (CCL and CAMB backends)
  • _ccl_to_camb / _camb_to_ccl / _cosmocov_to_ccl converters
  • tests/test_cosmology.py, ported from sp_validation

Additive — nothing existing changes

get_cosmo_default, the sigma_crit family, and xipm_theo are untouched (the diff is a header update plus one appended block), so shear_psf_leakage (which imports get_cosmo_default + xipm_theo) is unaffected. No new dependency — cs_util already requires camb and pyccl.

Real py3.12 support via a scipy cap

scipy 1.18 ported FITPACK to C, changing a RectBivariateSpline return shape that breaks camb's BBN Y_He predictor in set_cosmology — and pyccl's Boltzmann spline path — with TypeError: only 0-dimensional arrays can be converted to Python scalars. This caps scipy<1.18 (mirroring sp_validation), so the full cosmo suite passes for real on py3.10 and py3.12 (numpy 2.5): 31/31, no xfails. That also lets us drop the numpy≥2.5 xfail on test_xipm_theo (a stopgap for the same root cause, #70/#71), which now passes. Lift the cap when camb ships the fix — cmbant/CAMB#202 (workaround committed for camb's next release).

get_theo_xi produces the expected cosmic-shear ξ± (ξ+ ~1.5e-4 at 1′ → ~7e-7 at 200′).

Bumps version 0.2.1 → 0.2.2. The companion sp_validation PR (delete + repoint) follows.

— Claude on behalf of Cail

…ry into cs_util.cosmo

Move the cosmology theory-curve machinery from sp_validation.cosmology into
cs_util.cosmo so cs_util is the single home for the collaboration's cosmology
primitives (per a conversation with M. Kilbinger). Additive: no existing
cs_util.cosmo symbol changes, so shear_psf_leakage (get_cosmo_default,
xipm_theo) is unaffected.

Adds:
- PLANCK18 fiducial-cosmology dict
- get_cosmo: flexible Planck18-default cosmology builder (individual, CCL,
  CAMB, or CosmoCov parameter formats)
- get_theo_c_ell, c_ell_to_xi, get_theo_xi: angular power spectra and shear
  correlation functions, CCL and CAMB backends
- _ccl_to_camb / _camb_to_ccl / _cosmocov_to_ccl parameter converters
- tests/test_cosmology.py, ported from sp_validation

Caps scipy < 1.18 (mirroring sp_validation): scipy 1.18's FITPACK-to-C port
changed a RectBivariateSpline return shape that breaks camb's BBN Y_He
predictor in set_cosmology (and pyccl's Boltzmann spline path likewise). With
the cap the full cosmo suite passes for real on py3.10 AND py3.12 (numpy 2.5):
31/31. This also removes the numpy>=2.5 xfail on test_xipm_theo -- a stopgap
for the same root cause (#70/#71) -- which now passes.

Bumps version 0.2.1 -> 0.2.2. No new dependency (camb, pyccl already required).

Part of #75; the sp_validation delete + repoint follows in a companion PR.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013NCc4BHtZ4Lx6n9zuUwEeP
@cailmdaley cailmdaley force-pushed the feat/cosmo-from-sp_validation branch from 173f3b0 to fa0b8a0 Compare July 3, 2026 21:23
cailmdaley added a commit to CosmoStat/sp_validation that referenced this pull request Jul 3, 2026
…module

Companion to CosmoStat/cs_util#76, which brings sp_validation's cosmology
theory-curve machinery into cs_util.cosmo (the single home for the
collaboration's cosmology primitives, per a conversation with Martin).

Deletes src/sp_validation/cosmology.py and repoints every consumer to
cs_util.cosmo:
- package: b_modes.py, cosmo_val/core.py, cosmo_val/pseudo_cl.py
- scripts: papers/bmodes/scripts/precompute_pure_eb_chunk.py,
  scratch/guerrini/namaster_utils.py
- docs/comments: workflow/common.py, papers/bmodes/config/covariance.md

Drops "cosmology" from sp_validation.__all__ and removes the now-duplicated
tests/test_cosmology.py (moved to cs_util alongside the code). No call sites
change -- the functions are byte-identical, only their home moved.

Temporarily sources cs_util from #76's branch so this PR validates before #76
merges; restore "cs_util>=0.2.2" once #76 merges and 0.2.2 ships to PyPI.

Part of CosmoStat/cs_util#75.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013NCc4BHtZ4Lx6n9zuUwEeP
cailmdaley added a commit to CosmoStat/sp_validation that referenced this pull request Jul 3, 2026
cs_util releases are infrequent while the two repos iterate together, so
sp_validation tracks cs_util's develop branch directly as a git dependency
rather than a version pin. Replaces the temporary pointer at #76's feature
branch (which would break when that branch is deleted on merge). This PR's
cosmology repoint goes green once CosmoStat/cs_util#76 merges into develop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013NCc4BHtZ4Lx6n9zuUwEeP
@cailmdaley cailmdaley self-assigned this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate cosmology into cs_util (single home for the collaboration's cosmology primitives)

1 participant