Skip to content

Commit

Permalink
feat(backport): Improve warnings for qmu and qmu_tilde for the set PO…
Browse files Browse the repository at this point in the history
…I bounds

* Add information to the user in the warning that provides them with the
  higher level pyhf.infer APIs kwarg to set the correct test statistic.
  • Loading branch information
lorenzennio authored and matthewfeickert committed Jan 5, 2024
1 parent 3df4e52 commit 55aa4a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/contributors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Contributors include:
- Beojan Stanislaus
- Daniel Werner
- Jonas Rembser
- Lorenz Gaertner
6 changes: 4 additions & 2 deletions src/pyhf/infer/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def qmu(mu, data, pdf, init_pars, par_bounds, fixed_params, return_fitted_pars=F
if par_bounds[pdf.config.poi_index][0] == 0:
log.warning(
'qmu test statistic used for fit configuration with POI bounded at zero.\n'
+ 'Use the qmu_tilde test statistic (pyhf.infer.test_statistics.qmu_tilde) instead.'
+ 'Use the qmu_tilde test statistic (pyhf.infer.test_statistics.qmu_tilde) instead.\n'
+ 'If you called this from pyhf.infer.mle or pyhf.infer.hypotest, set test_stat="qtilde".'
)
return _qmu_like(
mu,
Expand Down Expand Up @@ -229,7 +230,8 @@ def qmu_tilde(
if par_bounds[pdf.config.poi_index][0] != 0:
log.warning(
'qmu_tilde test statistic used for fit configuration with POI not bounded at zero.\n'
+ 'Use the qmu test statistic (pyhf.infer.test_statistics.qmu) instead.'
+ 'Use the qmu test statistic (pyhf.infer.test_statistics.qmu) instead.\n'
+ 'If you called this from pyhf.infer.mle or pyhf.infer.hypotest, set test_stat="q".'
)
return _qmu_like(
mu,
Expand Down

0 comments on commit 55aa4a7

Please sign in to comment.