Skip to content

fix: restore lost setup scaffolding in chapter 2 tutorial_2_practicalities#14

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/tutorial-2-practicalities-rebuild
May 29, 2026
Merged

fix: restore lost setup scaffolding in chapter 2 tutorial_2_practicalities#14
Jammy2211 merged 1 commit into
mainfrom
feature/tutorial-2-practicalities-rebuild

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py was missing its imports, dataset load, mask and model setup — the first runnable line was search = af.Nautilus(...) referencing undefined dataset_name, dataset, and model, so the script could not run.

Root cause (confirmed by git history)

The code was deleted by a docs commit, not never-written:

Commit Lines Setup code present?
241cc8c0 "Add auto-simulate snippet" (autolens_workspace) 421
ce1bf623 "Add __Contents__ sections to all scripts" 302
62a5f3a bootstrap into HowToLens 303 ❌ (copied the broken file)

The __Contents__ commit pasted a new condensed Contents block over the region spanning the old Contents list down through the __Search__ prose, collaterally removing ~119 lines of setup code. The bootstrap then faithfully copied the already-broken file.

Fix

Restored the verbatim scaffolding from the last-complete version (241cc8c0): __PyAutoFit__, __Initial Setup__ (with auto-simulation), __Mask__, __Model__. Dataset = simple__no_lens_light__mass_sis (IsothermalSph mass + linear ExponentialCoreSph source) — the same fit as tutorial_1, matching the tutorial's own prose ("the same dataset we fitted in the previous tutorial").

Modernized to current-repo conventions: setup_notebook header, scripts/simulator/... subprocess path, PyAutoLabs/PyAutoFit URL. The existing body (search, analysis, VRAM, run-times, fit, results) is unchanged.

Verification

Runs end-to-end in fast mode (PYAUTO_TEST_MODE=2 + skip flags): model composes (6 free params), dataset loads (225 image-pixels after mask), search + likelihood evaluation complete, exit 0.

Scan for similar damage

Scanned both HowTo repos (current state) and the source commit's deletion footprint. tutorial_2 was the only tutorial damaged this way — all other candidates verified as false positives (search-chaining model_N naming; docstring code examples). HowToGalaxy's tutorial_2 is complete and unaffected.

Out of scope

Pre-existing stale prose in the kept body ("7 parameters", "single Sersic model with a linear light profile") predates the breakage — left for a separate prose-cleanup pass.

🤖 Generated with Claude Code

…ities

The imports, dataset load, mask and model setup were accidentally deleted
from this tutorial. Git history pinpoints the cause: the autolens_workspace
commit ce1bf623 "Add __Contents__ sections to all scripts" overwrote the
region spanning the old Contents list down through the __Search__ prose,
collaterally removing ~119 lines of setup code. The file dropped 421 -> 302
lines there. The later HowToLens bootstrap (62a5f3a) faithfully copied the
already-broken file, so the first runnable line was `search = af.Nautilus(...)`
referencing undefined `dataset_name`, `dataset` and `model`.

This restores the verbatim scaffolding from the last-complete version
(autolens_workspace 241cc8c0): imports, __PyAutoFit__, __Initial Setup__
(with auto-simulation), __Mask__ and __Model__. The dataset is
`simple__no_lens_light__mass_sis` (IsothermalSph mass + linear
ExponentialCoreSph source), the same fit as tutorial_1, matching the
tutorial's own prose ("the same dataset we fitted in the previous tutorial").

Modernized to current-repo conventions: setup_notebook header,
`scripts/simulator/...` subprocess path, and the PyAutoLabs/PyAutoFit URL.

Verified runnable end-to-end in fast mode
(PYAUTO_TEST_MODE=2 + skip flags): model composes (6 free params), dataset
loads, search and likelihood evaluation complete (exit 0).

Scanned both HowTo repos and the source commit's deletion footprint:
tutorial_2 was the only tutorial damaged this way; all other candidates were
verified false positives.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 merged commit 1e8d5c8 into main May 29, 2026
6 checks passed
@Jammy2211 Jammy2211 deleted the feature/tutorial-2-practicalities-rebuild branch May 29, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant