Skip to content

Commit 3c7bdc2

Browse files
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'.
1 parent cfc2f6f commit 3c7bdc2

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

.github/workflows/deploy-jupyter-book.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ jobs:
3535
run: |
3636
python -m pip list
3737
38+
- name: Set track_progress=False for notebooks
39+
run: |
40+
git config --global --add safe.directory /__w/pyhf-tutorial/pyhf-tutorial
41+
git grep --name-only "track_progress=True" book | xargs sed --in-place 's/track_progress=True/track_progress=False/g'
42+
3843
- name: Build the book
3944
run: |
4045
jupyter-book build book/

book/Toys.ipynb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@
6464
"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!)"
6565
]
6666
},
67-
{
68-
"cell_type": "markdown",
69-
"metadata": {},
70-
"source": [
71-
"```{note}\n",
72-
"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",
73-
"```"
74-
]
75-
},
7667
{
7768
"cell_type": "code",
7869
"execution_count": null,
@@ -87,7 +78,7 @@
8778
" return_expected_set=True,\n",
8879
" calctype=\"toybased\",\n",
8980
" ntoys=1_000,\n",
90-
" track_progress=False,\n",
81+
" track_progress=True,\n",
9182
")\n",
9283
"print(f\" Observed CLs: {CLs_obs:.4f}\")\n",
9384
"for expected_value, n_sigma in zip(CLs_exp, np.arange(-2, 3)):\n",
@@ -168,7 +159,7 @@
168159
" return_expected_set=True,\n",
169160
" calctype=\"toybased\",\n",
170161
" ntoys=5_000,\n",
171-
" track_progress=False,\n",
162+
" track_progress=True,\n",
172163
")\n",
173164
"print(f\" Observed CLs: {CLs_obs:.4f}\")\n",
174165
"for expected_value, n_sigma in zip(CLs_exp, np.arange(-2, 3)):\n",

book/UsingCalculators.ipynb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,14 @@
224224
"Let's create a toy-based calculator and \"throw\" 500 toys."
225225
]
226226
},
227-
{
228-
"cell_type": "markdown",
229-
"metadata": {},
230-
"source": [
231-
"```{note}\n",
232-
"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",
233-
"```"
234-
]
235-
},
236227
{
237228
"cell_type": "code",
238229
"execution_count": null,
239230
"metadata": {},
240231
"outputs": [],
241232
"source": [
242233
"toy_calc = pyhf.infer.calculators.ToyCalculator(\n",
243-
" data, model, test_stat=\"qtilde\", ntoys=500, track_progress=False\n",
234+
" data, model, test_stat=\"qtilde\", ntoys=500, track_progress=True\n",
244235
")"
245236
]
246237
},

0 commit comments

Comments
 (0)