Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent naming of baccoemu baryons object #1172

Merged
merged 4 commits into from May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmarks/test_baccoemu_baryons.py
Expand Up @@ -5,7 +5,7 @@


def test_baccoemu_baryons():
baryons = ccl.BaccoemuBaryons()
baryons = ccl.BaryonsBaccoemu()
cosmo = ccl.Cosmology(
Omega_c=0.27,
Omega_b=0.05,
Expand All @@ -32,7 +32,7 @@ def test_baccoemu_baryons():


def test_baccoemu_baryons_A_s():
baryons = ccl.BaccoemuBaryons()
baryons = ccl.BaryonsBaccoemu()
cosmo = ccl.Cosmology(
Omega_c=0.27,
Omega_b=0.05,
Expand Down
19 changes: 16 additions & 3 deletions pyccl/baryons/baccoemu_baryons.py
@@ -1,13 +1,14 @@
__all__ = ("BaccoemuBaryons",)
__all__ = ("BaryonsBaccoemu", "BaccoemuBaryons")

import numpy as np
from copy import deepcopy
from warnings import warn

from .. import Pk2D
from . import Baryons


class BaccoemuBaryons(Baryons):
class BaryonsBaccoemu(Baryons):
""" The baryonic boost factor computed with the baccoemu baryons emulators.

See `Arico et al. 2021 <https://arxiv.org/abs/2011.15018>`_ and
Expand All @@ -34,7 +35,7 @@ class BaccoemuBaryons(Baryons):
verbose (:obj:`bool`): Verbose output from baccoemu.
(default: :obj:`False`)
"""
name = 'BaccoemuBaryons'
name = 'BaryonsBaccoemu'
__repr_attrs__ = __eq_attrs__ = ("bcm_params",)

def __init__(self, log10_M_c=14.174, log10_eta=-0.3, log10_beta=-0.22,
Expand Down Expand Up @@ -208,3 +209,15 @@ def _check_a_range(self, a):
raise ValueError(f"Requested scale factor outside the bounds of "
f"the emulator: {(a_min, a_max)} outside of "
f"{((self.a_min, self.a_max))}")


class BaccoemuBaryons(BaryonsBaccoemu):
name = 'BaccoemuBaryons'

def __init__(self, *args, **kwargs):
"""This throws a deprecation warning on initialization."""
warn(f"Class {self.__class__.__name__} will be deprecated. " +
f"Please use {BaryonsBaccoemu.__name__} instead.",
DeprecationWarning, stacklevel=2)
super().__init__(*args, **kwargs)
pass
8 changes: 4 additions & 4 deletions pyccl/tests/test_baccoemu.py
Expand Up @@ -83,7 +83,7 @@ def test_baccoemu_nonlinear_As_sigma8():


def test_baccoemu_baryons_boost():
baryons = ccl.BaccoemuBaryons()
baryons = ccl.BaryonsBaccoemu()
nlpkemu = ccl.BaccoemuNonlinear()
cosmo = ccl.Cosmology(
Omega_c=0.27,
Expand All @@ -110,22 +110,22 @@ def test_baccoemu_baryons_boost():


def test_baccoemu_baryons_changepars():
baryons = ccl.BaccoemuBaryons()
baryons = ccl.BaryonsBaccoemu()
baryons.update_parameters(log10_M_c=12.7, log10_eta=-0.4)
assert ((baryons.bcm_params['M_c'] == 12.7)
& (baryons.bcm_params['eta'] == -0.4))


def test_baccoemu_baryons_a_range():
baryons = ccl.BaccoemuBaryons()
baryons = ccl.BaryonsBaccoemu()
cosmo = ccl.CosmologyVanillaLCDM()
k = 1e-1
with pytest.raises(ValueError):
baryons.boost_factor(cosmo, k, baryons.a_min * 0.9)


def test_baccoemu_baryons_As_sigma8():
baryons = ccl.BaccoemuBaryons()
baryons = ccl.BaryonsBaccoemu()
cosmo1 = ccl.Cosmology(
Omega_c=0.27,
Omega_b=0.05,
Expand Down