From 695a2c3e1f4bcfc2e93ddcd4530fbf2d15102af5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:18:39 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/flake8: 7.0.0 → 7.1.0](https://github.com/PyCQA/flake8/compare/7.0.0...7.1.0) - [github.com/asottile/pyupgrade: v3.16.0 → v3.17.0](https://github.com/asottile/pyupgrade/compare/v3.16.0...v3.17.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 72a3bac..7cf0a9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: @@ -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] From 62c452dfbcfea79d0dd3e8fa054b7d3712f9f16a Mon Sep 17 00:00:00 2001 From: Steven Murray Date: Tue, 30 Jul 2024 12:40:18 +0200 Subject: [PATCH 2/2] test: update tests to not warn for eh setting --- tests/test_cli.py | 1 + tests/test_framework.py | 13 +++++++++---- tests/test_functional.py | 1 + tests/test_hmf.py | 2 +- tests/test_mdef.py | 2 ++ tests/test_transfer.py | 3 +++ 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 84771ff..42cf7b9 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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)]) diff --git a/tests/test_framework.py b/tests/test_framework.py index 5699161..9981984 100644 --- a/tests/test_framework.py +++ b/tests/test_framework.py @@ -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) @@ -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 @@ -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 @@ -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) diff --git a/tests/test_functional.py b/tests/test_functional.py index a7e4eee..2a01b5e 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -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) diff --git a/tests/test_hmf.py b/tests/test_hmf.py index 689f6b9..bc3d611 100644 --- a/tests/test_hmf.py +++ b/tests/test_hmf.py @@ -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 diff --git a/tests/test_mdef.py b/tests/test_mdef.py index 4e8d556..204fc1b 100644 --- a/tests/test_mdef.py +++ b/tests/test_mdef.py @@ -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) diff --git a/tests/test_transfer.py b/tests/test_transfer.py index e904654..a3407b2 100644 --- a/tests/test_transfer.py +++ b/tests/test_transfer.py @@ -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 @@ -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)