From 0bf4ec7ebbdec1e046b7ae68c6de8590080e573a Mon Sep 17 00:00:00 2001 From: iasonkrom Date: Fri, 22 Mar 2024 23:28:04 +0100 Subject: [PATCH] update tests --- tests/test_pdf_erfexp.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_pdf_erfexp.py b/tests/test_pdf_erfexp.py index 7a4eab9..307f0ea 100644 --- a/tests/test_pdf_erfexp.py +++ b/tests/test_pdf_erfexp.py @@ -29,21 +29,28 @@ def _erfexp_numpy(x, alpha, beta, gamma, n): def create_erfexp(alpha, beta, gamma, n, limits): obs = zfit.Space("obs1", limits=limits) - erfexp = zphys.pdf.ErfExp(alpha=alpha, beta=beta, gamma=gamma, n=n, obs=obs, norm=False) + erfexp = zphys.pdf.ErfExp(alpha=alpha, beta=beta, gamma=gamma, n=n, obs=obs) return erfexp, obs def test_erfexp_pdf(): # Test PDF here erfexp, _ = create_erfexp(alpha=alpha_true, beta=beta_true, gamma=gamma_true, n=n_true, limits=(50, 130)) - assert erfexp.pdf(90.0).numpy().item() == pytest.approx( + 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 ) np.testing.assert_allclose( - erfexp.pdf(tf.range(50.0, 130, 10_000)), + 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), rtol=1e-8, ) + np.testing.assert_allclose( + erfexp.pdf(tf.range(50.0, 130, 10_000)), + erfexp_numpy(tf.range(50.0, 130, 10_000), alpha=alpha_true, beta=beta_true, gamma=gamma_true, n=n_true) + / 71.18838, + rtol=1e-8, + atol=1e-8, + ) def test_erfexp_pdf_random_params(): @@ -56,7 +63,7 @@ def test_erfexp_pdf_random_params(): erfexp, __ = create_erfexp(alpha=alpha_true, beta=beta_true, gamma=gamma_true, n=n_true, limits=(50, 130)) np.testing.assert_allclose( - erfexp.pdf(tf.range(50.0, 130, 10_000)), + 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), rtol=1e-5, )