diff --git a/docs/examples/notebooks/ImpactPlot.ipynb b/docs/examples/notebooks/ImpactPlot.ipynb index 783ac4dd2b..0d10ddcd4c 100644 --- a/docs/examples/notebooks/ImpactPlot.ipynb +++ b/docs/examples/notebooks/ImpactPlot.ipynb @@ -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, @@ -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" ] }, { @@ -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", diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py index df698b3c46..53ab261042 100644 --- a/tests/test_notebooks.py +++ b/tests/test_notebooks.py @@ -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):