From 3c7bdc2c19fab1d429991ad31e6dd62c36b64d7f Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Mon, 28 Aug 2023 16:12:42 -0500 Subject: [PATCH] chore: Set track_progress=True by default (#66) * Set `track_progress=True` for notebook files to give interactive users progress information. * Set `track_progess=False` during the JupyterBook build in CI to avoid having the updates of the progress bar information frozen into the built book. - Use `git config --global --add safe.directory` to guard against GitHub Actions environment erroring with 'fatal: detected dubious ownership in repository'. --- .github/workflows/deploy-jupyter-book.yml | 5 +++++ book/Toys.ipynb | 13 ++----------- book/UsingCalculators.ipynb | 11 +---------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy-jupyter-book.yml b/.github/workflows/deploy-jupyter-book.yml index c5a74a7..f72315b 100644 --- a/.github/workflows/deploy-jupyter-book.yml +++ b/.github/workflows/deploy-jupyter-book.yml @@ -35,6 +35,11 @@ jobs: run: | python -m pip list + - name: Set track_progress=False for notebooks + run: | + git config --global --add safe.directory /__w/pyhf-tutorial/pyhf-tutorial + git grep --name-only "track_progress=True" book | xargs sed --in-place 's/track_progress=True/track_progress=False/g' + - name: Build the book run: | jupyter-book build book/ diff --git a/book/Toys.ipynb b/book/Toys.ipynb index bba90cc..8ed4bc6 100644 --- a/book/Toys.ipynb +++ b/book/Toys.ipynb @@ -64,15 +64,6 @@ "So the question is, does the asymptotic approximation hold in this example? The standard assumption is that you have enough \"statistics\" (meaning enough events) to use the large-N approximation. So let's use the toy-based calculator instead and compute the same values as above and see if they match in the asymptotic case (we certainly hope they mostly do here!)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "```{note}\n", - "For readability in the Jupyter Book the `hypotest` has `track_progress=False`. If you're running this notebook yourself you might want to set `track_progress=True` to enable the progress bar.\n", - "```" - ] - }, { "cell_type": "code", "execution_count": null, @@ -87,7 +78,7 @@ " return_expected_set=True,\n", " calctype=\"toybased\",\n", " ntoys=1_000,\n", - " track_progress=False,\n", + " track_progress=True,\n", ")\n", "print(f\" Observed CLs: {CLs_obs:.4f}\")\n", "for expected_value, n_sigma in zip(CLs_exp, np.arange(-2, 3)):\n", @@ -168,7 +159,7 @@ " return_expected_set=True,\n", " calctype=\"toybased\",\n", " ntoys=5_000,\n", - " track_progress=False,\n", + " track_progress=True,\n", ")\n", "print(f\" Observed CLs: {CLs_obs:.4f}\")\n", "for expected_value, n_sigma in zip(CLs_exp, np.arange(-2, 3)):\n", diff --git a/book/UsingCalculators.ipynb b/book/UsingCalculators.ipynb index 9dd266d..a35aae0 100644 --- a/book/UsingCalculators.ipynb +++ b/book/UsingCalculators.ipynb @@ -224,15 +224,6 @@ "Let's create a toy-based calculator and \"throw\" 500 toys." ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "```{note}\n", - "For readability in the Jupyter Book the `ToyCalculator` has `track_progress=False`. If you're running this notebook yourself you might want to set `track_progress=True` to enable the progress bar.\n", - "```" - ] - }, { "cell_type": "code", "execution_count": null, @@ -240,7 +231,7 @@ "outputs": [], "source": [ "toy_calc = pyhf.infer.calculators.ToyCalculator(\n", - " data, model, test_stat=\"qtilde\", ntoys=500, track_progress=False\n", + " data, model, test_stat=\"qtilde\", ntoys=500, track_progress=True\n", ")" ] },