From ca8a1e14f46aa21aa66808f755bb68593f7b187e Mon Sep 17 00:00:00 2001 From: iasonkrom Date: Fri, 22 Mar 2024 23:35:05 +0100 Subject: [PATCH] also update cruijff tests in the same manner --- tests/test_pdf_cruijff.py | 31 ++++++++++++++++++++++++++++--- tests/test_pdf_erfexp.py | 3 +++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/test_pdf_cruijff.py b/tests/test_pdf_cruijff.py index 011fbc1..fdcce7a 100644 --- a/tests/test_pdf_cruijff.py +++ b/tests/test_pdf_cruijff.py @@ -19,7 +19,7 @@ def create_cruijff(mu, sigmal, alphal, sigmar, alphar, limits): obs = zfit.Space("obs1", limits=limits) - cruijff = zphys.pdf.Cruijff(mu=mu, sigmal=sigmal, alphal=alphal, sigmar=sigmar, alphar=alphar, obs=obs, norm=False) + cruijff = zphys.pdf.Cruijff(mu=mu, sigmal=sigmal, alphal=alphal, sigmar=sigmar, alphar=alphar, obs=obs) return cruijff, obs @@ -28,7 +28,7 @@ def test_cruijff_pdf(): cruijff, _ = create_cruijff( mu=mu_true, sigmal=sigmal_true, alphal=alphal_true, sigmar=sigmar_true, alphar=alphar_true, limits=(50, 130) ) - assert cruijff.pdf(90.0).numpy() == pytest.approx( + assert cruijff.pdf(90.0, norm=False).numpy() == pytest.approx( cruijff_numba.density( 90.0, beta_left=alphal_true, @@ -39,8 +39,20 @@ def test_cruijff_pdf(): ).item(), rel=1e-8, ) + assert cruijff.pdf(90.0).numpy() == pytest.approx( + cruijff_numba.density( + 90.0, + beta_left=alphal_true, + beta_right=alphar_true, + loc=mu_true, + scale_left=sigmal_true, + scale_right=sigmar_true, + ).item() + / 67.71494, + rel=1e-7, + ) np.testing.assert_allclose( - cruijff.pdf(tf.range(50.0, 130, 10_000)), + cruijff.pdf(tf.range(50.0, 130, 10_000), norm=False), cruijff_numba.density( tf.range(50.0, 130, 10_000).numpy(), beta_left=alphal_true, @@ -51,6 +63,19 @@ def test_cruijff_pdf(): ), rtol=1e-8, ) + np.testing.assert_allclose( + cruijff.pdf(tf.range(50.0, 130, 10_000)), + cruijff_numba.density( + tf.range(50.0, 130, 10_000).numpy(), + beta_left=alphal_true, + beta_right=alphar_true, + loc=mu_true, + scale_left=sigmal_true, + scale_right=sigmar_true, + ) + / 67.71494, + rtol=1e-8, + ) assert cruijff.pdf(tf.range(50.0, 130, 10_000)) <= cruijff.pdf(90.0) diff --git a/tests/test_pdf_erfexp.py b/tests/test_pdf_erfexp.py index 307f0ea..5eeada8 100644 --- a/tests/test_pdf_erfexp.py +++ b/tests/test_pdf_erfexp.py @@ -39,6 +39,9 @@ def test_erfexp_pdf(): assert erfexp.pdf(90.0, norm=False).numpy().item() == pytest.approx( erfexp_numpy(90.0, alpha=alpha_true, beta=beta_true, gamma=gamma_true, n=n_true), rel=1e-8 ) + assert erfexp.pdf(90.0).numpy().item() == pytest.approx( + erfexp_numpy(90.0, alpha=alpha_true, beta=beta_true, gamma=gamma_true, n=n_true) / 71.18838, rel=1e-8 + ) np.testing.assert_allclose( erfexp.pdf(tf.range(50.0, 130, 10_000), norm=False), erfexp_numpy(tf.range(50.0, 130, 10_000), alpha=alpha_true, beta=beta_true, gamma=gamma_true, n=n_true),