From fa6c03fb9f970d7370251f55c67e92a254b134e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 18 Aug 2026 12:10:22 +0000 Subject: [PATCH] Add the missing setup_notebook() line to HowToFit tutorial scripts Every workspace/tutorial script opens with # from autofit 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 Claude-Session: https://claude.ai/code/session_0126SmBwHMzP4okcjhjPoLFZ --- notebooks/chapter_1_introduction/start_here.ipynb | 10 ++++++++++ .../chapter_1_introduction/tutorial_1_models.ipynb | 2 ++ scripts/chapter_1_introduction/start_here.py | 2 ++ scripts/chapter_1_introduction/tutorial_1_models.py | 2 ++ start_here.ipynb | 2 ++ start_here.py | 2 ++ 6 files changed, 20 insertions(+) diff --git a/notebooks/chapter_1_introduction/start_here.ipynb b/notebooks/chapter_1_introduction/start_here.ipynb index 40c5f77..de7b864 100644 --- a/notebooks/chapter_1_introduction/start_here.ipynb +++ b/notebooks/chapter_1_introduction/start_here.ipynb @@ -96,6 +96,16 @@ "\n", "_setup_colab.setup(\"howtofit\")" ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "\n", + "from autofit import setup_notebook; setup_notebook()" + ], + "outputs": [], + "execution_count": null } ], "metadata": { diff --git a/notebooks/chapter_1_introduction/tutorial_1_models.ipynb b/notebooks/chapter_1_introduction/tutorial_1_models.ipynb index b9fd4f2..fd4d8ee 100644 --- a/notebooks/chapter_1_introduction/tutorial_1_models.ipynb +++ b/notebooks/chapter_1_introduction/tutorial_1_models.ipynb @@ -116,6 +116,8 @@ "cell_type": "code", "metadata": {}, "source": [ + "\n", + "from autofit import setup_notebook; setup_notebook()\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", diff --git a/scripts/chapter_1_introduction/start_here.py b/scripts/chapter_1_introduction/start_here.py index e2d4d5e..7b68652 100644 --- a/scripts/chapter_1_introduction/start_here.py +++ b/scripts/chapter_1_introduction/start_here.py @@ -53,3 +53,5 @@ alongside the larger `autofit_workspace_developer/projects/cosmology/` example. These depend on astronomy-specific datasets that only live in the developer workspace. """ + +# from autofit import setup_notebook; setup_notebook() diff --git a/scripts/chapter_1_introduction/tutorial_1_models.py b/scripts/chapter_1_introduction/tutorial_1_models.py index 85a8453..ee92d05 100644 --- a/scripts/chapter_1_introduction/tutorial_1_models.py +++ b/scripts/chapter_1_introduction/tutorial_1_models.py @@ -69,6 +69,8 @@ performed by PyAutoFit. """ +# from autofit import setup_notebook; setup_notebook() + import numpy as np import matplotlib.pyplot as plt diff --git a/start_here.ipynb b/start_here.ipynb index 54a3356..a445285 100644 --- a/start_here.ipynb +++ b/start_here.ipynb @@ -96,6 +96,8 @@ "cell_type": "code", "metadata": {}, "source": [ + "\n", + "from autofit import setup_notebook; setup_notebook()\n", "\n", "print(__doc__)\n" ], diff --git a/start_here.py b/start_here.py index 3966f50..3619637 100644 --- a/start_here.py +++ b/start_here.py @@ -49,4 +49,6 @@ Open `scripts/chapter_1_introduction/start_here.py` (or the `.ipynb` equivalent) and start there. """ +# from autofit import setup_notebook; setup_notebook() + print(__doc__)