Skip to content

Commit 1ff2fa0

Browse files
committed
Add the missing setup_notebook() line to HowToLens tutorial scripts
Every workspace/tutorial script opens with # from autolens import setup_notebook; setup_notebook() right after the module docstring; the line chdir's to the workspace root and enables inline plotting when the generated notebook is run. A handful of scripts never got it. Without it a tutorial that loads data by a relative path (or shells out to a simulator) fails under nbconvert, which runs with CWD set to the notebook's own directory, and works interactively only if the user happened to launch jupyter from the repo root. This is the full audit of every chapter in the repo (plus the root start_here.py): the missing line is added in the sibling convention's exact position and the generated notebooks are updated to match, uncommented, the way PyAutoHands emits them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0126SmBwHMzP4okcjhjPoLFZ
1 parent ed2b8ff commit 1ff2fa0

12 files changed

Lines changed: 48 additions & 0 deletions

File tree

notebooks/chapter_2_lens_modeling/tutorial_11_slam.ipynb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@
108108
"\n",
109109
"_setup_colab.setup(\"howtolens\")"
110110
]
111+
},
112+
{
113+
"cell_type": "code",
114+
"metadata": {},
115+
"source": [
116+
"\n",
117+
"from autolens import setup_notebook; setup_notebook()"
118+
],
119+
"outputs": [],
120+
"execution_count": null
111121
}
112122
],
113123
"metadata": {

notebooks/chapter_2_lens_modeling/tutorial_8_need_for_speed.ipynb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@
203203
"\n",
204204
"_setup_colab.setup(\"howtolens\")"
205205
]
206+
},
207+
{
208+
"cell_type": "code",
209+
"metadata": {},
210+
"source": [
211+
"\n",
212+
"from autolens import setup_notebook; setup_notebook()"
213+
],
214+
"outputs": [],
215+
"execution_count": null
206216
}
207217
],
208218
"metadata": {

notebooks/chapter_3_pixelizations/tutorial_9_model_fit.ipynb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@
5454
"\n",
5555
"_setup_colab.setup(\"howtolens\")"
5656
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"metadata": {},
61+
"source": [
62+
"\n",
63+
"from autolens import setup_notebook; setup_notebook()"
64+
],
65+
"outputs": [],
66+
"execution_count": null
5767
}
5868
],
5969
"metadata": {

notebooks/simulator/lens_x2.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
"cell_type": "code",
8888
"metadata": {},
8989
"source": [
90+
"\n",
91+
"from autolens import setup_notebook; setup_notebook()\n",
9092
"\n",
9193
"from pathlib import Path\n",
9294
"import autolens as al\n",

notebooks/simulator/lens_x3.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
"cell_type": "code",
8989
"metadata": {},
9090
"source": [
91+
"\n",
92+
"from autolens import setup_notebook; setup_notebook()\n",
9193
"\n",
9294
"from pathlib import Path\n",
9395
"import autolens as al\n",

scripts/chapter_2_lens_modeling/tutorial_11_slam.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,5 @@
6565
This tutorial concludes the lens modeling chapter. In the next chapter, we introduce pixelizations, which reconstruct
6666
the source galaxy on a pixel-grid rather than with light profiles.
6767
"""
68+
69+
# from autolens import setup_notebook; setup_notebook()

scripts/chapter_2_lens_modeling/tutorial_8_need_for_speed.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,5 @@
160160
passing (tutorial 10) reduce the number of evaluations needed to fit complex models, and the SLaM pipelines
161161
(tutorial 11) package these ideas into automated pipelines for fitting large samples of lenses.
162162
"""
163+
164+
# from autolens import setup_notebook; setup_notebook()

scripts/chapter_3_pixelizations/tutorial_9_model_fit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
Once complete, you can then move on to the next HowToLens tutorial and gain more insight into adaptive
1212
pixelizations.
1313
"""
14+
15+
# from autolens import setup_notebook; setup_notebook()

scripts/simulator/lens_x2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
If any code in this script is unclear, refer to the `autolens_workspace/*/imaging/simulator.ipynb` notebook.
4141
"""
4242

43+
# from autolens import setup_notebook; setup_notebook()
44+
4345
from pathlib import Path
4446
import autolens as al
4547
import autolens.plot as aplt

scripts/simulator/lens_x3.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
If any code in this script is unclear, refer to the `autolens_workspace/*/imaging/simulator.ipynb` notebook.
4242
"""
4343

44+
# from autolens import setup_notebook; setup_notebook()
45+
4446
from pathlib import Path
4547
import autolens as al
4648
import autolens.plot as aplt

0 commit comments

Comments
 (0)