Skip to content

Commit 7b296cc

Browse files
authored
refactor: Create infer subpackage to hold our statistics code (#531)
* Create a pyhf.infer subpackage * Move cli.stats to cli.infer * Bump version: 0.2.2 → 0.3.0
1 parent 1347b96 commit 7b296cc

33 files changed

+1412
-405
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.2
2+
current_version = 0.3.0
33
commit = True
44
tag = True
55

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This repo is a pure-python implementation of that statistical model for multi-bi
3232
```python
3333
>>> import pyhf
3434
>>> pdf = pyhf.simplemodels.hepdata_like(signal_data=[12.0, 11.0], bkg_data=[50.0, 52.0], bkg_uncerts=[3.0, 7.0])
35-
>>> CLs_obs, CLs_exp = pyhf.utils.hypotest(1.0, [51, 48] + pdf.config.auxdata, pdf, return_expected=True)
35+
>>> CLs_obs, CLs_exp = pyhf.infer.hypotest(1.0, [51, 48] + pdf.config.auxdata, pdf, return_expected=True)
3636
>>> print('Observed: {}, Expected: {}'.format(CLs_obs, CLs_exp))
3737
Observed: [0.05290116], Expected: [0.06445521]
3838

docs/api.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@ Interpolators
109109
code4
110110
code4p
111111

112+
Statistics
113+
----------
114+
115+
.. currentmodule:: pyhf.infer
116+
117+
.. autosummary::
118+
:toctree: _generated/
119+
120+
test_statistics.hypotest
121+
test_statistics.qmu
122+
utils.loglambdav
123+
utils.generate_asimov_data
124+
112125
Exceptions
113126
----------
114127

@@ -141,9 +154,5 @@ Utilities
141154
.. autosummary::
142155
:toctree: _generated/
143156

144-
generate_asimov_data
145-
loglambdav
146157
pvals_from_teststat
147158
pvals_from_teststat_expected
148-
qmu
149-
hypotest

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def setup(app):
8686
# built documents.
8787
#
8888
# The short X.Y version.
89-
version = u'0.2.2'
89+
version = u'0.3.0'
9090
# The full version, including alpha/beta/rc tags.
91-
release = u'0.2.2'
91+
release = u'0.3.0'
9292

9393
# The language for content autogenerated by Sphinx. Refer to documentation
9494
# for a list of supported languages.
@@ -162,7 +162,7 @@ def setup(app):
162162
# The name for this set of Sphinx documents.
163163
# "<project> v<release> documentation" by default.
164164
#
165-
# html_title = u'pyhf v0.2.2'
165+
# html_title = u'pyhf v0.3.0'
166166

167167
# A shorter title for the navigation bar. Default is the same as html_title.
168168
#

docs/examples/notebooks/ImpactPlot.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
" pyhf.tensor.numpy_backend(), pyhf.optimize.minuit_optimizer(verbose=True)\n",
8686
" )\n",
8787
" minuit = pyhf.optimizer._make_minuit(\n",
88-
" pyhf.utils.loglambdav,\n",
88+
" pyhf.infer.utils.loglambdav,\n",
8989
" data,\n",
9090
" model,\n",
9191
" model.config.suggested_init(),\n",

docs/examples/notebooks/Recast.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"source": [
116116
"testmus = np.linspace(0,5)\n",
117117
"results = [\n",
118-
" pyhf.utils.hypotest(mu, data + original.config.auxdata, \n",
118+
" pyhf.infer.hypotest(mu, data + original.config.auxdata, \n",
119119
" original, original.config.suggested_init(), original.config.suggested_bounds(),\n",
120120
" return_expected_set=True)\n",
121121
" for mu in testmus\n",
@@ -205,7 +205,7 @@
205205
"source": [
206206
"testmus = np.linspace(0,5)\n",
207207
"results = [\n",
208-
" pyhf.utils.hypotest(mu, data + recast.config.auxdata, \n",
208+
" pyhf.infer.hypotest(mu, data + recast.config.auxdata, \n",
209209
" recast, recast.config.suggested_init(), recast.config.suggested_bounds(),\n",
210210
" return_expected_set=True)\n",
211211
" for mu in testmus\n",

docs/examples/notebooks/ShapeFactor.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"source": [
182182
"print('initialization parameters: {}'.format(pdf.config.suggested_init()))\n",
183183
"\n",
184-
"unconpars = pyhf.optimizer.unconstrained_bestfit(pyhf.utils.loglambdav, data, pdf,\n",
184+
"unconpars = pyhf.optimizer.unconstrained_bestfit(pyhf.infer.utils.loglambdav, data, pdf,\n",
185185
" pdf.config.suggested_init(), pdf.config.suggested_bounds())\n",
186186
"print('parameters post unconstrained fit: {}'.format(unconpars))"
187187
]
@@ -252,7 +252,7 @@
252252
"\n",
253253
"\n",
254254
"poi_tests = np.linspace(0, 5, 61)\n",
255-
"tests = [pyhf.utils.hypotest(poi_test, data, pdf, init_pars, par_bounds, return_expected_set=True) \n",
255+
"tests = [pyhf.infer.hypotest(poi_test, data, pdf, init_pars, par_bounds, return_expected_set=True) \n",
256256
" for poi_test in poi_tests]\n",
257257
"cls_obs = np.array([test[0] for test in tests]).flatten()\n",
258258
"cls_exp = [np.array([test[1][i] for test in tests]).flatten() for i in range(5)]\n",

docs/examples/notebooks/binderexample/StatisticalAnalysis.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@
10731073
"background_only = pdf.config.suggested_init()\n",
10741074
"background_only[pdf.config.poi_index] = 0.0\n",
10751075
"best_fit = pyhf.optimizer.unconstrained_bestfit(\n",
1076-
" pyhf.utils.loglambdav, data, pdf, pdf.config.suggested_init(), pdf.config.suggested_bounds())"
1076+
" pyhf.infer.utils.loglambdav, data, pdf, pdf.config.suggested_init(), pdf.config.suggested_bounds())"
10771077
]
10781078
},
10791079
{
@@ -2740,7 +2740,7 @@
27402740
],
27412741
"source": [
27422742
"mu_tests = np.linspace(0, 1, 16)\n",
2743-
"hypo_tests = [pyhf.utils.hypotest(mu, data, pdf, pdf.config.suggested_init(), pdf.config.suggested_bounds(),\n",
2743+
"hypo_tests = [pyhf.infer.hypotest(mu, data, pdf, pdf.config.suggested_init(), pdf.config.suggested_bounds(),\n",
27442744
" return_expected_set=True, return_test_statistics=True)\n",
27452745
" for mu in mu_tests]\n",
27462746
"\n",

0 commit comments

Comments
 (0)