Skip to content

Commit e506094

Browse files
Merge branch 'master' into feat/skip-workspace-validation
2 parents fa123a8 + 43c1567 commit e506094

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

docs/examples/notebooks/pullplot.ipynb

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,26 @@
88
"source": [
99
"import pyhf\n",
1010
"import json\n",
11-
"import copy\n",
1211
"import numpy as np\n",
1312
"import matplotlib.pyplot as plt\n",
1413
"\n",
1514
"%matplotlib inline"
1615
]
1716
},
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {},
20+
"source": [
21+
"## Download the Model"
22+
]
23+
},
24+
{
25+
"cell_type": "markdown",
26+
"metadata": {},
27+
"source": [
28+
"For this example we'll download the archive of probability models for the ATLAS analysis [JHEP 12 (2019) 060, 2019](https://inspirehep.net/literature/1748602) from its [HEPData page](https://www.hepdata.net/record/ins1748602) using its [specific DOI](https://www.hepdata.net/record/resource/1935437?landing_page=true). You can download this multiple ways, but for simplicity we'll download it using the `pyhf contrib download` command"
29+
]
30+
},
1831
{
1932
"cell_type": "code",
2033
"execution_count": 2,
@@ -24,19 +37,32 @@
2437
"name": "stdout",
2538
"output_type": "stream",
2639
"text": [
27-
"RegionA/BkgOnly.json\n"
40+
"\u001b[01;34m1Lbb-probability-models\u001b[00m\n",
41+
"├── README.md\n",
42+
"├── \u001b[01;34mRegionA\u001b[00m\n",
43+
"│   ├── BkgOnly.json\n",
44+
"│   └── patchset.json\n",
45+
"├── \u001b[01;34mRegionB\u001b[00m\n",
46+
"│   ├── BkgOnly.json\n",
47+
"│   └── patchset.json\n",
48+
"└── \u001b[01;34mRegionC\u001b[00m\n",
49+
" ├── BkgOnly.json\n",
50+
" └── patchset.json\n",
51+
"\n",
52+
"3 directories, 7 files\n"
2853
]
2954
}
3055
],
3156
"source": [
32-
"!curl -sL https://doi.org/10.17182/hepdata.89408.v1/r2 | tar -O -xzv RegionA/BkgOnly.json > lhood.json"
57+
"! pyhf contrib download https://doi.org/10.17182/hepdata.89408.v3/r2 1Lbb-probability-models\n",
58+
"! tree 1Lbb-probability-models"
3359
]
3460
},
3561
{
3662
"cell_type": "markdown",
3763
"metadata": {},
3864
"source": [
39-
"### Create the Model and Fit it\n"
65+
"## Create the Model and Fit it\n"
4066
]
4167
},
4268
{
@@ -46,8 +72,7 @@
4672
"outputs": [],
4773
"source": [
4874
"def make_model(channel_list):\n",
49-
" spec = json.load(open(\"lhood.json\"))\n",
50-
" spec = copy.copy(spec)\n",
75+
" spec = json.load(open(\"1Lbb-probability-models/RegionA/BkgOnly.json\"))\n",
5176
" spec[\"channels\"] = [c for c in spec[\"channels\"] if c[\"name\"] in channel_list]\n",
5277
" spec[\"measurements\"][0][\"config\"][\"poi\"] = \"lumi\"\n",
5378
"\n",
@@ -186,7 +211,7 @@
186211
],
187212
"metadata": {
188213
"kernelspec": {
189-
"display_name": "Python 3",
214+
"display_name": "Python 3 (ipykernel)",
190215
"language": "python",
191216
"name": "python3"
192217
},
@@ -200,7 +225,7 @@
200225
"name": "python",
201226
"nbconvert_exporter": "python",
202227
"pygments_lexer": "ipython3",
203-
"version": "3.7.5"
228+
"version": "3.9.6"
204229
}
205230
},
206231
"nbformat": 4,

tests/test_notebooks.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ def test_multibinpois(common_kwargs):
5555

5656

5757
def test_pullplot(common_kwargs):
58-
pm.execute_notebook('docs/examples/notebooks/pullplot.ipynb', **common_kwargs)
58+
# Change directories to make users not have to worry about paths to follow example
59+
cwd = os.getcwd()
60+
os.chdir(os.path.join(cwd, "docs/examples/notebooks"))
61+
pm.execute_notebook("pullplot.ipynb", **common_kwargs)
62+
os.chdir(cwd)
5963

6064

6165
def test_impactplot(common_kwargs):

0 commit comments

Comments
 (0)