-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
failing tests for return_fitted_pars in generate_asimov_data
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |