Skip to content

Commit

Permalink
Merge pull request #224 from halomod/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
steven-murray authored Jul 30, 2024
2 parents c0e86b9 + 62c452d commit 443971c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
- id: mixed-line-ending
args: ['--fix=no']
- repo: https://github.com/PyCQA/flake8
rev: '7.0.0' # pick a git hash / tag to point to
rev: '7.1.0' # pick a git hash / tag to point to
hooks:
- id: flake8
additional_dependencies:
Expand Down Expand Up @@ -46,7 +46,7 @@ repos:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py38-plus]
1 change: 1 addition & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def tmpdir(tmp_path_factory) -> Path:
return tmp_path_factory.mktemp("cli-tests")


@pytest.mark.filterwarnings("ignore:'extrapolate_with_eh' was not set")
def test_no_config_or_args(tmpdir: Path):
runner = CliRunner()
result = runner.invoke(main, ["run", "--outdir", str(tmpdir)])
Expand Down
13 changes: 9 additions & 4 deletions tests/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_incorrect_argument():

def test_incorrect_update_arg():
with raises(ValueError):
t = hmf.MassFunction()
t = hmf.MassFunction(transfer_model="EH")
t.update(wrong_arg=3)


Expand All @@ -28,19 +28,22 @@ def cls():

@pytest.fixture(scope="class")
def inst(cls):
return cls(z=10)
return cls(z=10, transfer_model="EH")


@pytest.mark.filterwarnings("ignore:'extrapolate_with_eh' was not set")
def test_parameter_names(cls):
assert "cosmo_model" in cls.get_all_parameter_names()


@pytest.mark.filterwarnings("ignore:'extrapolate_with_eh' was not set")
def test_parameter_defaults(cls):
assert type(cls.get_all_parameter_defaults(recursive=False)) is dict

assert cls.get_all_parameter_defaults()["z"] == 0


@pytest.mark.filterwarnings("ignore:'extrapolate_with_eh' was not set")
def test_parameter_default_rec(cls):
pd = cls.get_all_parameter_defaults(recursive=True)
assert type(pd["cosmo_params"]) is dict
Expand All @@ -51,10 +54,12 @@ def test_param_values(inst):
assert inst.parameter_values["z"] == 10


@pytest.mark.filterwarnings("ignore:'extrapolate_with_eh' was not set")
def test_qnt_avail(cls):
assert "dndm" in cls.quantities_available()


@pytest.mark.filterwarnings("ignore:'extrapolate_with_eh' was not set")
def test_parameter_info(cls):
assert cls.parameter_info() is None
assert cls.parameter_info(names=["z"]) is None
Expand Down Expand Up @@ -95,9 +100,9 @@ def test_growth_plugins():

def test_validate_inputs():
with pytest.raises(AssertionError):
MassFunction(Mmin=10, Mmax=9)
MassFunction(Mmin=10, Mmax=9, transfer_model="EH")

m = MassFunction(Mmin=10, Mmax=11)
m = MassFunction(Mmin=10, Mmax=11, transfer_model="EH")
with pytest.raises(AssertionError):
m.update(Mmax=9)

Expand Down
1 change: 1 addition & 0 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_order():
z=list(range(3)),
hmf_model=["ST", "PS"],
sigma_8=[0.7, 0.8],
transfer_model="EH",
)
):
print(i)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def test_str_filter():


def test_mass_nonlinear_outside_range():
h = MassFunction(Mmin=8, Mmax=9)
h = MassFunction(Mmin=8, Mmax=9, transfer_model="EH")
with pytest.warns(UserWarning):
assert h.mass_nonlinear > 0
2 changes: 2 additions & 0 deletions tests/test_mdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ def test_change_dndm_bocquet():
mdef_model="SOMean",
mdef_params={"overdensity": 200},
hmf_model="Bocquet200mDMOnly",
transfer_model="EH",
)
h200c = MassFunction(
mdef_model="SOCritical",
mdef_params={"overdensity": 200},
hmf_model="Bocquet200cDMOnly",
transfer_model="EH",
)

np.testing.assert_allclose(h200m.fsigma / h200c.fsigma, h200m.dndm / h200c.dndm)
3 changes: 3 additions & 0 deletions tests/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_camb_w0wa():
cosmo_model=w0waCDM(
Om0=0.3, Ode0=0.7, w0=-1, wa=0.03, Ob0=0.05, H0=70.0, Tcmb0=2.7
),
transfer_params={"extrapolate_with_eh": True},
)
assert t.transfer_function.shape == t.k.shape

Expand All @@ -105,11 +106,13 @@ def test_camb_wCDM():
t = Transfer(
transfer_model="CAMB",
cosmo_model=wCDM(Om0=0.3, Ode0=0.7, w0=-1, Ob0=0.05, H0=70.0, Tcmb0=2.7),
transfer_params={"extrapolate_with_eh": True},
)

t2 = Transfer(
transfer_model="CAMB",
cosmo_model=LambdaCDM(Om0=0.3, Ode0=0.7, Ob0=0.05, H0=70.0, Tcmb0=2.7),
transfer_params={"extrapolate_with_eh": True},
)
np.testing.assert_array_almost_equal(t.transfer_function, t2.transfer_function)

Expand Down

0 comments on commit 443971c

Please sign in to comment.