Skip to content

Commit 7867023

Browse files
feat: Update tutorial to use pyhf v0.6.2 (#8)
* Update to pyhf v0.6.2 and update API changes - pyhf.simplemodels.hepdata_like -> pyhf.simplemodels.uncorrelated_background - brazil.plot_results(ax, poi_values, results) -> brazil.plot_results(poi_values, results, ax=ax) - Update URLs to point to v0.6.2 * Update number of published full statistical models to 8 - Change language from 'likelihoods' to 'statistical models' in keeping with upcoming white paper * Update citation format * Update pre-commit hooks
1 parent 2377e02 commit 7867023

12 files changed

+45
-44
lines changed

.github/workflows/deploy-jupyter-book.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip setuptools wheel
26-
python -m pip install --no-cache-dir -r binder/requirements.txt
27-
python -m pip install --no-cache-dir -r book/requirements.txt
26+
python -m pip --no-cache-dir install -r binder/requirements.txt
27+
python -m pip --no-cache-dir install -r book/requirements.txt
2828
2929
- name: Build the book
3030
run: |

.pre-commit-config.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22

33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v3.4.0
4+
rev: v4.0.1
55
hooks:
66
- id: check-added-large-files
77
- id: check-case-conflict
@@ -16,22 +16,22 @@ repos:
1616
- id: mixed-line-ending
1717
- id: trailing-whitespace
1818

19-
- repo: https://github.com/psf/black
20-
rev: 20.8b1
21-
hooks:
22-
- id: black
23-
2419
- repo: https://github.com/asottile/pyupgrade
25-
rev: v2.11.0
20+
rev: v2.19.4
2621
hooks:
2722
- id: pyupgrade
2823

24+
- repo: https://github.com/psf/black
25+
rev: 21.6b0
26+
hooks:
27+
- id: black
28+
2929
- repo: https://github.com/nbQA-dev/nbQA
30-
rev: 0.6.0
30+
rev: 0.13.0
3131
hooks:
32-
- id: nbqa-black
33-
additional_dependencies: [black==20.8b1]
3432
- id: nbqa-pyupgrade
35-
additional_dependencies: [pyupgrade==2.11.0]
33+
additional_dependencies: [pyupgrade==2.19.4]
3634
- id: nbqa-isort
37-
additional_dependencies: [isort==5.8.0]
35+
additional_dependencies: [isort==5.9.1]
36+
- id: nbqa-black
37+
additional_dependencies: [black==21.6b0]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Tutorial last given at the [April 2021 PyHEP topical meeting](https://indico.cern.ch/event/985425/).
44

5-
**The tutorial is based off of [`pyhf` `v0.6.1`](https://pypi.org/project/pyhf/0.6.1/)**
5+
**The tutorial is based off of [`pyhf` `v0.6.2`](https://pypi.org/project/pyhf/0.6.2/)**
66

77
[![Deploy Jupyter Book](https://github.com/pyhf/pyhf-tutorial/workflows/Deploy%20Jupyter%20Book/badge.svg?branch=main)](https://pyhf.github.io/pyhf-tutorial/)
88
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/pyhf/pyhf-tutorial/main?urlpath=lab)

binder/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pyhf[xmlio,minuit,contrib]==0.6.1
1+
pyhf[xmlio,minuit,contrib]==0.6.2
22
# visualization
33
ipywidgets~=7.5
44
pandas~=1.0

book/HelloWorld.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"metadata": {},
4040
"outputs": [],
4141
"source": [
42-
"model = pyhf.simplemodels.hepdata_like(\n",
43-
" signal_data=[5.0, 10.0], bkg_data=[50.0, 60.0], bkg_uncerts=[5.0, 12.0]\n",
42+
"model = pyhf.simplemodels.uncorrelated_background(\n",
43+
" signal=[5.0, 10.0], bkg=[50.0, 60.0], bkg_uncertainty=[5.0, 12.0]\n",
4444
")\n",
4545
"model"
4646
]
@@ -49,7 +49,7 @@
4949
"cell_type": "markdown",
5050
"metadata": {},
5151
"source": [
52-
"What did we just make? This returns a [`pyhf.pdf.Model`](https://pyhf.readthedocs.io/en/v0.6.1/_generated/pyhf.pdf.Model.html#pyhf.pdf.Model) object. Let's check out the specification."
52+
"What did we just make? This returns a [`pyhf.pdf.Model`](https://pyhf.readthedocs.io/en/v0.6.2/_generated/pyhf.pdf.Model.html#pyhf.pdf.Model) object. Let's check out the specification."
5353
]
5454
},
5555
{
@@ -144,7 +144,7 @@
144144
"\n",
145145
"where $n = \\{n_1, n_2\\}$ for a 2-bin model (we're being slightly fast and loose with our mathematical notation here), and similarly for $s$, $b$, and $\\gamma$.\n",
146146
"\n",
147-
"The 'shapesys' is defined in the [HistFactory paper](https://cds.cern.ch/record/1456844)... however, it can be a little hard to extract out the necessary information. We've provided a nice table of [Modifiers and Constraints](https://pyhf.readthedocs.io/en/v0.6.1/intro.html#id24) in the introduction of our pyhf documentation to use as reference.\n",
147+
"The 'shapesys' is defined in the [HistFactory paper](https://cds.cern.ch/record/1456844)... however, it can be a little hard to extract out the necessary information. We've provided a nice table of [Modifiers and Constraints](https://pyhf.readthedocs.io/en/v0.6.2/intro.html#id24) in the introduction of our pyhf documentation to use as reference.\n",
148148
"\n",
149149
"![modifiers and constraints](assets/modifiers_and_constraints.png)"
150150
]
@@ -515,7 +515,7 @@
515515
"cell_type": "markdown",
516516
"metadata": {},
517517
"source": [
518-
"We're not performing inference just yet. We're simply computing the 'logpdf' of the model specified by the parameters $\\theta$ against the provided data. To perform a fit, we use the [inference API](https://pyhf.readthedocs.io/en/v0.6.1/api.html#inference) via `pyhf.infer`.\n",
518+
"We're not performing inference just yet. We're simply computing the 'logpdf' of the model specified by the parameters $\\theta$ against the provided data. To perform a fit, we use the [inference API](https://pyhf.readthedocs.io/en/v0.6.2/api.html#inference) via `pyhf.infer`.\n",
519519
"\n",
520520
"When fitting a model to data, we usually want to find the $\\hat{\\theta}$ which refers to the \"Maximum Likelihood Estimate\" of the model parameters. This is often referred to mathematically by\n",
521521
"\n",
@@ -675,7 +675,7 @@
675675
"source": [
676676
"## Simple Upper Limit\n",
677677
"\n",
678-
"To get upper limits, we just need to run multiple hypothesis tests for a lot of different null hypotheses of BSM with $\\mu \\in [0, \\ldots, 5.0]$ and then find the value of $\\mu$ for which the null hypothesis is rejected (a 95% $\\text{CL}_\\text{s}$). We can do all of this very easily just using the [`upperlimit` API](https://pyhf.readthedocs.io/en/v0.6.1/_generated/pyhf.infer.intervals.upperlimit.html), which also can calculate the upper limit by interpolating"
678+
"To get upper limits, we just need to run multiple hypothesis tests for a lot of different null hypotheses of BSM with $\\mu \\in [0, \\ldots, 5.0]$ and then find the value of $\\mu$ for which the null hypothesis is rejected (a 95% $\\text{CL}_\\text{s}$). We can do all of this very easily just using the [`upperlimit` API](https://pyhf.readthedocs.io/en/v0.6.2/_generated/pyhf.infer.intervals.upperlimit.html), which also can calculate the upper limit by interpolating"
679679
]
680680
},
681681
{
@@ -713,7 +713,7 @@
713713
"fig.set_size_inches(10.5, 7)\n",
714714
"ax.set_title(\"Hypothesis Tests\")\n",
715715
"\n",
716-
"brazil.plot_results(ax, poi_values, results)"
716+
"artists = brazil.plot_results(poi_values, results, ax=ax)"
717717
]
718718
},
719719
{

book/Modifiers.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"\n",
99
"In our simple examples so far, we've only used two types of modifiers, but HistFactory allows for a handful of modifiers that have proven to be sufficient to model a wide range of uncertainties.\n",
1010
"\n",
11-
"We've provided a nice table of [Modifiers and Constraints](https://pyhf.readthedocs.io/en/v0.6.1/intro.html#id24) in the introduction of our pyhf documentation to use as reference.\n",
11+
"We've provided a nice table of [Modifiers and Constraints](https://pyhf.readthedocs.io/en/v0.6.2/intro.html#id24) in the introduction of our pyhf documentation to use as reference.\n",
1212
"\n",
1313
"![modifiers and constraints](assets/modifiers_and_constraints.png)\n",
1414
"\n",

book/SerializationAndPatching.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"cell_type": "markdown",
3131
"metadata": {},
3232
"source": [
33-
"As of this tutorial, ATLAS has [published 7 full likelihoods to HEPData](https://pyhf.readthedocs.io/en/v0.6.1/citations.html#published-likelihoods)\n",
33+
"As of this tutorial, ATLAS has [published 8 full statistical models to HEPData](https://pyhf.readthedocs.io/en/v0.6.2/citations.html#published-statistical-models)\n",
3434
"\n",
3535
"<p align=\"center\">\n",
3636
"<a href=\"https://www.hepdata.net/record/ins1755298?version=3\"><img src=\"https://raw.githubusercontent.com/matthewfeickert/talk-SciPy-2020/e0c509cd0dfef98f5876071edd4c60aff9199a1b/figures/HEPData_likelihoods.png\"></a>\n",
@@ -107,7 +107,7 @@
107107
"source": [
108108
"## Patching in Signals\n",
109109
"\n",
110-
"Let's look at this [`pyhf.PatchSet`](https://pyhf.readthedocs.io/en/v0.6.1/_generated/pyhf.patchset.PatchSet.html#pyhf.patchset.PatchSet) object which provides a user-friendly way to interact with many signal patches at once.\n",
110+
"Let's look at this [`pyhf.PatchSet`](https://pyhf.readthedocs.io/en/v0.6.2/_generated/pyhf.patchset.PatchSet.html#pyhf.patchset.PatchSet) object which provides a user-friendly way to interact with many signal patches at once.\n",
111111
"\n",
112112
"### PatchSet"
113113
]

book/SimpleWorkspace.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"metadata": {},
3636
"outputs": [],
3737
"source": [
38-
"model = pyhf.simplemodels.hepdata_like(\n",
39-
" signal_data=[5.0, 10.0], bkg_data=[50.0, 60.0], bkg_uncerts=[5.0, 12.0]\n",
38+
"model = pyhf.simplemodels.uncorrelated_background(\n",
39+
" signal=[5.0, 10.0], bkg=[50.0, 60.0], bkg_uncertainty=[5.0, 12.0]\n",
4040
")\n",
4141
"print(json.dumps(model.spec, indent=2))"
4242
]
@@ -67,7 +67,7 @@
6767
"cell_type": "markdown",
6868
"metadata": {},
6969
"source": [
70-
"What did we just make? This returns a [`pyhf.Workspace`](https://pyhf.readthedocs.io/en/v0.6.1/_generated/pyhf.workspace.Workspace.html#pyhf.workspace.Workspace) object. Let's check out the specification."
70+
"What did we just make? This returns a [`pyhf.Workspace`](https://pyhf.readthedocs.io/en/v0.6.2/_generated/pyhf.workspace.Workspace.html#pyhf.workspace.Workspace) object. Let's check out the specification."
7171
]
7272
},
7373
{
@@ -158,7 +158,7 @@
158158
"source": [
159159
"What does this mean for us though? Well, when we ask for a model, we specify the measurement that we want to use with it. Each of these measurements above have no additional parameter configurations on top of the existing model specification. Additionally, they all declare that the parameter of interest is `mu`.\n",
160160
"\n",
161-
"See the [documentation](https://pyhf.readthedocs.io/en/v0.6.1/_generated/pyhf.workspace.Workspace.html#pyhf.workspace.Workspace.model) for more information. In this case, let's build the model for the default measurement."
161+
"See the [documentation](https://pyhf.readthedocs.io/en/v0.6.2/_generated/pyhf.workspace.Workspace.html#pyhf.workspace.Workspace.model) for more information. In this case, let's build the model for the default measurement."
162162
]
163163
},
164164
{

book/Toys.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"import numpy as np\n",
2626
"import pyhf\n",
2727
"\n",
28-
"model = pyhf.simplemodels.hepdata_like(\n",
29-
" signal_data=[5.0, 10.0], bkg_data=[50.0, 60.0], bkg_uncerts=[5.0, 12.0]\n",
28+
"model = pyhf.simplemodels.uncorrelated_background(\n",
29+
" signal=[5.0, 10.0], bkg=[50.0, 60.0], bkg_uncertainty=[5.0, 12.0]\n",
3030
")"
3131
]
3232
},
@@ -106,8 +106,8 @@
106106
"metadata": {},
107107
"outputs": [],
108108
"source": [
109-
"model_low = pyhf.simplemodels.hepdata_like(\n",
110-
" signal_data=[0.5, 1.0], bkg_data=[5.0, 6.0], bkg_uncerts=[0.5, 1.2]\n",
109+
"model_low = pyhf.simplemodels.uncorrelated_background(\n",
110+
" signal=[0.5, 1.0], bkg=[5.0, 6.0], bkg_uncertainty=[0.5, 1.2]\n",
111111
")"
112112
]
113113
},

book/UsingCalculators.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"metadata": {},
3939
"outputs": [],
4040
"source": [
41-
"model = pyhf.simplemodels.hepdata_like([6], [9], [3])\n",
41+
"model = pyhf.simplemodels.uncorrelated_background([6], [9], [3])\n",
4242
"data = [9] + model.config.auxdata"
4343
]
4444
},

0 commit comments

Comments
 (0)