Skip to content

fix: consolidate guides/results tutorials onto one _quick_fit.py (aggregator IndexError)#275

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/aggregator-quick-fit-consolidation
Jul 14, 2026
Merged

fix: consolidate guides/results tutorials onto one _quick_fit.py (aggregator IndexError)#275
Jammy2211 merged 1 commit into
mainfrom
feature/aggregator-quick-fit-consolidation

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Overview

Fixes the IndexError: list index out of range crashes in the guides/results aggregator tutorials (release-validation tail cluster E, PyAutoHeart#72). Closes the diagnosis in #274.

Three results tutorials each ran their own capped n_like_max=300 Nautilus fit, but only _quick_fit.py disables samples_weight_threshold. The others pruned to 2 samples on disk, so their deep sample indexing (from_sample_index(-10), parameter_lists[9]) raised IndexError once the release profile ran the real sampler (guides/results/ unsets PYAUTO_TEST_MODE, so is_test_mode() is False and PyAutoFit#1368 does not apply). It is order-dependent: start_here.py runs first and plants the 2-sample fit that the aggregator readers then choke on. The scripts' docstrings claimed to resume _quick_fit's fit, but the model configs had diverged.

This consolidates onto a single fit source, _quick_fit.py: it gets a suffix-free primary unique_tag (simple__no_lens_light) plus one more (_1) for the aggregator's multi-result iteration, and the three self-fitting scripts' inline model is made to match it (Isothermal + external shear, MGE source). search.fit() then genuinely resumes the 300-sample fit. The identifier is [search, model, unique_tag] only, so a plain AnalysisImaging inline still resumes _quick_fit's AnalysisLatent fit — no shared "builder" imports, the model stays written out inline in each teaching script.

Scripts Changed

  • scripts/guides/results/_quick_fit.py — primary fit unique_tag made suffix-free (simple__no_lens_light) + one more (_1) for aggregator iteration; keeps samples_weight_threshold = None, shear + MGE model, AnalysisLatent.
  • scripts/guides/results/start_here.py — added shear=al.mp.ExternalShear so the inline model matches _quick_fit; search.fit() now resumes the 300-sample fit (docstring now accurate).
  • scripts/guides/results/aggregator/galaxies_fits.py — same shear addition; from_sample_index(-10) now valid.
  • scripts/guides/results/aggregator/samples.py — source Sersic → MGE bulge + shear; the two source.bulge.sersic_index filter examples retargeted to lens.shear.gamma_1; parameter_lists[9] now valid.
  • Regenerated notebooks: notebooks/guides/results/{_quick_fit,start_here,aggregator/galaxies_fits,aggregator/samples}.ipynb.

Bonus: fixes aggregator/queries.py, whose unique_tag == "simple__no_lens_light" query previously matched nothing (only _0/_1 existed).

Validation checklist (--auto)

  • Tests — n/a (workspace repo, no pytest suite).
  • Smoke — ordered guides/results run under config/build/env_vars_release.yaml (the release profile that reproduced the bug): 14/14 pass (previously aggregator/galaxies_fits.py and aggregator/samples_via_aggregator.py failed with IndexError). On disk both fits retain 300 samples; no 2-sample fit is created. Identifier check: the inline tutorial config computes aceb0b5a8cddadad1a489ab941e694cb, identical to _quick_fit's primary fit → resume confirmed.
  • Review — self CLEAN: 8 files (+90/−22), 4 scripts + their 4 regenerated notebooks, scope is exactly the consolidation, no unrelated changes.
  • Heart — RED (see corrective-red record below); shipped under the human-authorized corrective-PR exception.

Corrective-PR exception for Heart RED

  • Reason clearedrelease validation FAILED (stage integrate) (the aggregator IndexErrors = cluster E of PyAutoHeart#72).
  • Authorizationfix: consolidate guides/results fits onto _quick_fit.py (IndexError) #274 (comment) (human, quoting the exact reason).
  • Causal map — Heart integrate failure → fix: consolidate guides/results fits onto _quick_fit.py (IndexError) #274 aggregator IndexError (shallow tutorial fits pruned to 2 samples) → consolidate onto _quick_fit's 300-sample fit → this PR.
  • Scope — one pending-release PR only; no merge, no issue close, no release, no rehearsal. Merge stays a separate human act.
  • Sibling RED reasons remainPyAutoLens/PyAutoGalaxy behind origin, workspace validation not passing (3 failed), 58 stale parked scripts, PyAutoMind open PR 14d old, install verification not run. This PR clears only the aggregator/cluster-E portion of the stage-integrate reason, so Heart stays RED and release stays blocked until every reason is cleared by its own corrective PR.

Recovery

After a human merges this: build fresh post-merge wheels, re-run release-integration validation on main, and obtain a new Heart verdict before any release decision.

🤖 Generated with Claude Code

Refs #274 (kept open — corrective validation pending; the exception forbids issue close)

start_here.py, aggregator/galaxies_fits.py and aggregator/samples.py each
ran their own capped n_like_max=300 Nautilus fit, but only _quick_fit.py
disables samples_weight_threshold. The others pruned to 2 samples on disk,
so their deep sample indexing (from_sample_index(-10), parameter_lists[9])
raised IndexError once the release profile ran the real sampler
(guides/results/ unsets PYAUTO_TEST_MODE, so is_test_mode() is False and
PyAutoFit#1368 does not apply). Order-dependent: start_here.py runs first
and plants the 2-sample fit the aggregator readers then choke on.

Consolidate onto a single fit source, _quick_fit.py: give it a suffix-free
primary unique_tag (simple__no_lens_light) plus one more (_1) for the
aggregator's multi-result iteration, and make the three self-fitting
scripts' inline model match it (Isothermal + external shear, MGE source).
search.fit() then genuinely resumes the 300-sample fit instead of running
a divergent shallow one, making the scripts' "resumes from the cached fit"
docstrings true. The fit identifier is [search, model, unique_tag] only, so
a plain AnalysisImaging inline still resumes _quick_fit's AnalysisLatent
fit. samples.py's source changes Sersic -> MGE to match, and its two
source.bulge.sersic_index filter examples move to lens.shear.gamma_1. Also
fixes queries.py, whose unique_tag == "simple__no_lens_light" query
previously matched nothing.

Validated: ordered guides/results run under env_vars_release.yaml passes
14/14 (was 2 IndexError failures); both fits retain 300 samples on disk,
no 2-sample fit. Notebooks regenerated. Resolves the aggregator portion
(cluster E) of the release-validation tail, PyAutoHeart#72.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 14, 2026
@Jammy2211 Jammy2211 merged commit c17ddfa into main Jul 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant