From 55aa4a7a3a20635e0ac69fe3065bec3632dde399 Mon Sep 17 00:00:00 2001 From: Lorenz Gaertner Date: Fri, 8 Dec 2023 11:48:56 +0100 Subject: [PATCH] feat(backport): Improve warnings for qmu and qmu_tilde for the set POI 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. --- docs/contributors.rst | 1 + src/pyhf/infer/test_statistics.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/contributors.rst b/docs/contributors.rst index c2d0b0a698..d29fd0974b 100644 --- a/docs/contributors.rst +++ b/docs/contributors.rst @@ -33,3 +33,4 @@ Contributors include: - Beojan Stanislaus - Daniel Werner - Jonas Rembser +- Lorenz Gaertner diff --git a/src/pyhf/infer/test_statistics.py b/src/pyhf/infer/test_statistics.py index 3af773d42c..cf11e09c86 100644 --- a/src/pyhf/infer/test_statistics.py +++ b/src/pyhf/infer/test_statistics.py @@ -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, @@ -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,