Skip to content

Commit

Permalink
failing tests for return_fitted_pars in generate_asimov_data
Browse files Browse the repository at this point in the history
  • Loading branch information
lhenkelm committed Aug 17, 2021
1 parent 04b0c3b commit 51c3d15
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/test_calculator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
import pytest

import pyhf
import pyhf.infer.calculators


def test_calc_dist():
asymptotic_dist = pyhf.infer.calculators.AsymptoticTestStatDistribution(0.0)
assert asymptotic_dist.pvalue(-1) == 1 - asymptotic_dist.cdf(-1)


@pytest.mark.parametrize("return_fitted_pars", [False, True])
def test_generate_asimov_can_return_fitted_pars(return_fitted_pars):
model = pyhf.simplemodels.uncorrelated_background([1, 1], [1, 1], [1, 1])
data = [2, 2, 1, 1] # [main x 2, aux x 2]
init_pars = model.config.suggested_init()
par_bounds = model.config.suggested_bounds()
fixed_params = model.config.suggested_fixed()

result = pyhf.infer.calculators.generate_asimov_data(
1.0,
data,
model,
init_pars,
par_bounds,
fixed_params,
return_fitted_pars=return_fitted_pars,
)

if return_fitted_pars:
assert len(result) == 2
result, asimov_pars = result
# asimov_pars and result could be tensors, so convert to List[float] first
assert list(map(float, asimov_pars)) == [
1.0,
1.0,
1.0,
] # mu, 2x uncorr_bkguncrt
assert list(map(float, result)) == [2.0, 2.0, 1.0, 1.0]

0 comments on commit 51c3d15

Please sign in to comment.