Skip to content

Commit

Permalink
also update cruijff tests in the same manner
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrommyd committed Mar 22, 2024
1 parent 0bf4ec7 commit ca8a1e1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
31 changes: 28 additions & 3 deletions tests/test_pdf_cruijff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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)


Expand Down
3 changes: 3 additions & 0 deletions tests/test_pdf_erfexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit ca8a1e1

Please sign in to comment.