Skip to content

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

Merged
cailmdaley merged 1 commit into
developfrom
feat/cosmo-from-sp_validation
Jul 6, 2026
Merged

feat(cosmo): consolidate sp_validation cosmology theory-curve machinery into cs_util.cosmo#76
cailmdaley merged 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).
Closes #71

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
@cailmdaley

Copy link
Copy Markdown
Collaborator Author

@sachaguer please take a look at this when you have a chance, would be good to settle this before doing too much more sp_validation development

@sachaguer

Copy link
Copy Markdown
Collaborator

@sachaguer please take a look at this when you have a chance, would be good to settle this before doing too much more sp_validation development

Nothing specific related to this from my side. I will keep working and as soon as this is merged the CI will not pass and I will update my import. The overall structure of sp_validation should not be impacted.

@cailmdaley cailmdaley merged commit dad294b into develop Jul 6, 2026
5 checks passed
@cailmdaley cailmdaley deleted the feat/cosmo-from-sp_validation branch July 6, 2026 08:40
cailmdaley added a commit to CosmoStat/sp_validation that referenced this pull request Jul 6, 2026
…module (#223)

* refactor(cosmology): move cosmology into cs_util.cosmo; delete local 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

* build: track cs_util's develop branch (not a PyPI pin)

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

* refactor: repoint remaining PLANCK18 references to cs_util.cosmo

workflow/rules/covariance.smk imported sp_validation.cosmology.PLANCK18
inside the cosmology_params rule's embedded python — a runtime break
once cosmology.py is deleted. Repoint it and the two comment/docstring
references (generate_cosmocov_ini.py, papers/bmodes config) to
cs_util.cosmo.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ExsQmDDttuhMxSZ6BWmMr9

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants