Skip to content

gh-492: Adding running of the spectral index and curvature emulators#493

Merged
gcanasherrera merged 9 commits into
mainfrom
curvature-nrun-emu
May 11, 2026
Merged

gh-492: Adding running of the spectral index and curvature emulators#493
gcanasherrera merged 9 commits into
mainfrom
curvature-nrun-emu

Conversation

@ivansladoljev

@ivansladoljev ivansladoljev commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

🚀 Pull Request Checklist

✅ Summary

Adds curvature and running spectral index emulators to the CosmoPowerJAX module, and adds alpha_s support to CAMBBackground.

🔄 Changes per file

  • camb_cosmology.py

CAMBBackground.__init__: added alpha_s: float = 0.0 (optional, after N_ur)
CAMBBackground: added self.alpha_s = alpha_s and passes it to InitPower.set_params(..., nrun=self.alpha_s)
CAMBNonLinearPerturbations.__init__: added linearperturbations parameter (typed Optional["CAMBLinearPerturbations"])

  • class_cosmology.py
    CLASSBackground.__init__: added **kwargs to accept (and ignore) CAMB-specific params like alpha_s

  • 'jax_cosmology.py`

JAXBackground.__init__: added **kwargs for the same reason

  • cosmopower_jax_cosmology.py

Added support for 2-degenerate-neutrino models (N_mnu=2) for w0waCDM/wCDM/LCDM
Updated Zenodo URL to new record
Renamed emulator .npz filenames (e.g. w0wa-linear-spectra.npzw0wa-linear.npz)
Added CosmoPowerJAXCurvaturePerturbations and CosmoPowerJAXRunningIndexPerturbations classes
Added k_modes_curvature_path

  • docs/code_structure/background.md

Updated CosmoPowerJAX description (linear+nonlinear), added emulator class table, added alpha_s=0.0 to example

  • docs/code_structure/summary_statistics.md
    Removed broken #performance-tips link from warning admonition; added ## Performance Tips section below it

  • tests/test_baccoemu.py

Added alpha_s=0.0 to CAMBBackground fixture

  • tests/test_bnt.py

Added alpha_s=0.0 to _cosmo_pars and to the required attributes set

  • tests/test_camb_cosmology.py

Added alpha_s=0.0 to all CAMBBackground instantiations
Added linearperturbations=None (or None positionally) to all CAMBNonLinearPerturbations calls
Added new test test_camb_background_running_spectral_index

  • tests/test_camb_photo_z0_compatibility.py

Added alpha_s=0.0 to CAMBBackground; added None to CAMBNonLinearPerturbations call
tests/test_cmb.py

Added alpha_s=0.0 to CAMBBackground; added None to CAMBNonLinearPerturbations calls
tests/test_cosmology_background.py`

Added alpha_s=0.0 to _cosmo_pars; removed alpha_s from attributes_required set (since it was removed from the protocol)

  • tests/test_cosmopower_jax_emulators.py

Added alpha_s=0.0 to DummyBackground
Added background_w0wa_2degen fixture
Added imports for CosmoPowerJAXCurvaturePerturbations and CosmoPowerJAXRunningIndexPerturbations

🛠 How to Test

pytest tests/test_cosmopower_jax_emulators.py -v
pytest tests/test_camb_cosmology.py -v

📝 Documentation

  • This PR updates documentation
  • This PR does not require documentation changes
  • Issue created for documentation update: Don't forget to link the task!

🏗 Related Issues

Resolves #492


✅ PR Checklist for Developers

  • I have titled this PR before merging as "gh-#:", where "#" represents the task it closes
  • I have run locally pre-commit using pre-commit run --all-files
  • I have tested my changes locally
  • No new warnings or errors introduced
  • I have updated documentation (if applicable)
  • My changes do not introduce breaking changes (i.e: the package still gets installed)
  • I have added unit tests (if applicable)
  • I have consistently updated the GitHub information for the project, including milestones, task types, and other relevant details.

✅ PR Checklist for Reviewers

  • The next PR targets the correct branch
  • CI tests have run and passed for the latest commit on the source branch
  • Check that the code can still be installed if new packages are imported
  • If necessary, the notebooks in the playground will be updated in a corresponding follow-up PR
  • Coverage percentage is retained or increased
  • Quality of new/changed code is acceptable
  • Quality of new/changed unit tests is acceptable
  • No data files have been included in the commits
  • Implementation follows the agreed task description point by point
  • Check that any added folder/file has been added to the README.md file
  • Check that the documentation has been updated accordantly
  • Check that the corresponding branch has been deleted after merging. If not, delete it

@ivansladoljev ivansladoljev changed the title Adding running of the spectral index and curvature emulators gh-492: Adding running of the spectral index and curvature emulators Apr 21, 2026
@ivansladoljev ivansladoljev added background-perturbations Tasks related to Background and Perturbations th-1 labels Apr 21, 2026
@gcanasherrera gcanasherrera added this to the v0.11 milestone May 4, 2026
@gcanasherrera

Copy link
Copy Markdown
Member

Hi @ivansladoljev,

  • Conflicts might need to be resolved
  • Also, is there a follow up playground to update the notebooks and scripts?

@ivansladoljev

Copy link
Copy Markdown
Collaborator Author

Hi @ivansladoljev,

  • Conflicts might need to be resolved
  • Also, is there a follow up playground to update the notebooks and scripts?

Ok, I will update and solve any new conflicts that have arisen.

Regarding the playground, there is an initial PR for cosmopower in playground [https://github.com/cloe-org/playground/pull/140]. Maybe once that is merged, I can update it with new emulators (or we can do it all in one big PR, since there is not a lot of difference between everything).

@gcanasherrera

Copy link
Copy Markdown
Member

Sure, we can update that one later, but also, we need to update anything related to CAMB and CLASS as you are adding an extra parameter there :)

@ivansladoljev

Copy link
Copy Markdown
Collaborator Author

Sure, we can update that one later, but also, we need to update anything related to CAMB and CLASS as you are adding an extra parameter there :)

Yes. This PR addresses all the tests for CAMB/CLASS in cloelib, but for playground and cloelike there will be other PR's.

For cloelike, there is already a PR for fixing nonlinear perturbations (just the cosmetic one) cloe-org/cloelike#121, and the one for alpha_s cloe-org/cloelike#123.

For the playground there are fixes for nonlinear perturbations (cloe-org/playground#138). which are kind of URGENT, since we merged the fixes into cloelib.
I can add the alpha_s changes to the overall cosmopower notebook PR, same as here (cloe-org/playground#140).

@gcanasherrera
gcanasherrera merged commit b0d5532 into main May 11, 2026
7 checks passed
@gcanasherrera
gcanasherrera deleted the curvature-nrun-emu branch May 11, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

background-perturbations Tasks related to Background and Perturbations th-1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding running of the spectral index and curvature emulators

2 participants