Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure that setting upper limit works for toms748 scan #2564

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/pyhf/infer/intervals/upper_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def upper_limit(
model,
bounds[0],
bounds[1],
level=level,
from_upper_limit_fn=True,
**hypotest_kwargs,
)
Expand Down
25 changes: 25 additions & 0 deletions tests/test_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,3 +642,28 @@ def test_deprecated_upperlimit(hypotest_args):
"pyhf.infer.intervals.upperlimit is deprecated in favor of pyhf.infer.intervals.upper_limits.upper_limit"
in str(_warning[-1].message)
)


def test_issue2563_toms748_scan_setLevel(tmp_path, hypotest_args):
"""
Test that setting the level actually gives us what we expect for scan=None (using the toms748 algorithm)
"""
_, data, model = hypotest_args

obs_limit_95, exp_limits_95 = pyhf.infer.intervals.upper_limits.upper_limit(
data, model, rtol=1e-8, level=0.05, scan=None
)

obs_limit_90, exp_limits_90 = pyhf.infer.intervals.upper_limits.upper_limit(
data, model, rtol=1e-8, level=0.10, scan=None
)

assert obs_limit_95 != pytest.approx(
obs_limit_90
), "Observed limit at 95% is the same as the observed limit at 90%"
for index, (exp_limit_95, exp_limit_90) in enumerate(
zip(exp_limits_95, exp_limits_90), 1
):
assert exp_limit_95 != pytest.approx(
exp_limit_90
), f"Expected limit for 95% is the same as the expected limit at 90% for position {index}"
Loading