Skip to content

Commit

Permalink
docs: Fix download method of probability models archive in impact plo…
Browse files Browse the repository at this point in the history
…t notebook (#1721)

* Use stable DOI https://doi.org/10.17182/hepdata.89408.v3/r2 to download
probability models archive from HEPData.
   - This version of the 1Lbb probability models uses a pyhf PatchSet, so
     update the impact plot notebook accordingly.
* Use `pyhf contrib download` as it can properly accept HEPData headers.
* Change directories for the impact plot notebook test so that the paths used
in the notebook do not have to be changed to accommodate testing paths.
  • Loading branch information
matthewfeickert authored Dec 5, 2021
1 parent b798ef2 commit e3c21aa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
33 changes: 27 additions & 6 deletions docs/examples/notebooks/ImpactPlot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
"## Download the Model\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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."
]
},
{
"cell_type": "code",
"execution_count": 2,
Expand All @@ -34,14 +41,25 @@
"name": "stdout",
"output_type": "stream",
"text": [
"RegionA/BkgOnly.json\n",
"RegionA/patch.sbottom_750_745_60.json\n"
"\u001b[01;34m1Lbb-probability-models\u001b[00m\n",
"├── README.md\n",
"├── \u001b[01;34mRegionA\u001b[00m\n",
"│   ├── BkgOnly.json\n",
"│   └── patchset.json\n",
"├── \u001b[01;34mRegionB\u001b[00m\n",
"│   ├── BkgOnly.json\n",
"│   └── patchset.json\n",
"└── \u001b[01;34mRegionC\u001b[00m\n",
" ├── BkgOnly.json\n",
" └── patchset.json\n",
"\n",
"3 directories, 7 files\n"
]
}
],
"source": [
"!curl -sL https://doi.org/10.17182/hepdata.89408.v1/r2 | tar -O -xzv RegionA/BkgOnly.json > lhood.json\n",
"!curl -sL https://doi.org/10.17182/hepdata.89408.v1/r2 | tar -O -xzv RegionA/patch.sbottom_750_745_60.json > patch.json"
"! pyhf contrib download https://doi.org/10.17182/hepdata.89408.v3/r2 1Lbb-probability-models\n",
"! tree 1Lbb-probability-models"
]
},
{
Expand All @@ -58,8 +76,11 @@
"outputs": [],
"source": [
"def make_model(channel_list):\n",
" spec = json.load(open(\"lhood.json\"))\n",
" patch = json.load(open(\"patch.json\"))\n",
" spec = json.load(open(\"1Lbb-probability-models/RegionA/BkgOnly.json\"))\n",
" patchset = pyhf.PatchSet(\n",
" json.load(open(\"1Lbb-probability-models/RegionA/patchset.json\"))\n",
" )\n",
" patch = patchset[\"sbottom_750_745_60\"]\n",
" spec = jsonpatch.apply_patch(spec, patch)\n",
" spec[\"channels\"] = [c for c in spec[\"channels\"] if c[\"name\"] in channel_list]\n",
"\n",
Expand Down
6 changes: 5 additions & 1 deletion tests/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ def test_pullplot(common_kwargs):


def test_impactplot(common_kwargs):
pm.execute_notebook('docs/examples/notebooks/ImpactPlot.ipynb', **common_kwargs)
# Change directories to make users not have to worry about paths to follow example
cwd = os.getcwd()
os.chdir(os.path.join(cwd, "docs/examples/notebooks"))
pm.execute_notebook("ImpactPlot.ipynb", **common_kwargs)
os.chdir(cwd)


def test_toys(common_kwargs):
Expand Down

0 comments on commit e3c21aa

Please sign in to comment.