Skip to content

Commit

Permalink
chore: Set track_progress=True by default (#66)
Browse files Browse the repository at this point in the history
* 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'.
  • Loading branch information
matthewfeickert authored Aug 28, 2023
1 parent cfc2f6f commit 3c7bdc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/deploy-jupyter-book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
13 changes: 2 additions & 11 deletions book/Toys.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 1 addition & 10 deletions book/UsingCalculators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,14 @@
"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,
"metadata": {},
"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",
")"
]
},
Expand Down

0 comments on commit 3c7bdc2

Please sign in to comment.