Skip to content

Commit

Permalink
switch to approx, use kwargs to clean up slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
kratsg authored and matthewfeickert committed Jan 15, 2021
1 parent 4ba1200 commit 1f64782
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,8 @@ def expected_result_1bin_shapesys_q0():
@pytest.fixture(scope='module')
def expected_result_1bin_shapesys_q0_toys():
expected_result = {
"exp": [
0.0,
0.0,
0.01,
0.0965,
0.3865,
],
"obs": 0.003,
"exp": [0.0, 0.0005, 0.0145, 0.1205, 0.403],
"obs": 0.005,
}
return expected_result

Expand Down Expand Up @@ -652,20 +646,21 @@ def validate_hypotest(
init_pars = pdf.config.suggested_init()
par_bounds = pdf.config.suggested_bounds()

kwargs = {'return_expected_set': True, 'test_stat': test_stat, 'calctype': calctype}

np.random.seed(0)
CLs_obs, CLs_exp_set = pyhf.infer.hypotest(
mu_test,
data,
pdf,
init_pars,
par_bounds,
return_expected_set=True,
test_stat=test_stat,
calctype=calctype,
**kwargs,
)

assert abs(CLs_obs - expected_result['obs']) / expected_result['obs'] < tolerance
for result, expected in zip(CLs_exp_set, expected_result['exp']):
assert abs(result - expected) / expected < tolerance, result
assert result == pytest.approx(expected, rel=tolerance), result


@pytest.fixture(
Expand Down

0 comments on commit 1f64782

Please sign in to comment.