Skip to content

fix: tutorials hardcode stored-sample index 9, crash under low-sample profiles #140

Description

@Jammy2211

Overview

Results/database/aggregator tutorial scripts across four workspaces hardcode stored-sample index 9 ("the tenth sample"): samples.parameter_lists[9][k] and, in several, log_likelihood_list[9] / log_prior_list[9] / log_posterior_list[9] / weight_list[9]. Any stored run with fewer than 10 samples — e.g. PYAUTO_TEST_MODE fake searches used by local validation sweeps — raises IndexError. Real-search runs pass, so the break is latent in CI but bites every test-mode sweep (found 2026-08-19 while validating PyAutoLabs/PyAutoFit#1504; evidence on PyAutoLabs/PyAutoFit#1486). autogalaxy_workspace's two aggregator guides were previously part-fixed to [0] but kept the now-wrong "tenth sample" prose and redundantly re-print the first sample.

Plan

  • Unify the idiom across the family: print the final sample via [-1] with matching "final sample" prose — always valid for any non-empty sample list, and it demonstrates a different sample from the [0] printed just above.
  • Apply to every site the sweep found (8 scripts, 4 repos); one PR per repo.
  • Validate: autocti's database chain now runs under PYAUTO_TEST_MODE=1 (fewer than 10 stored samples), so a test-mode run crashes before this fix and passes after — a direct regression proof; autofit's cookbooks/result.py is in its smoke list.
Detailed implementation plan

Affected Repositories

  • autofit_workspace (primary — the cookbook the others copy)
  • autogalaxy_workspace
  • autolens_workspace
  • autocti_workspace

Sites (from a full-workspace sweep)

  • autofit_workspace/scripts/cookbooks/result.py:428parameter_lists[9][2]
  • autogalaxy_workspace/scripts/guides/results/database/start_here.py:359parameter_lists[9][2]
  • autogalaxy_workspace/scripts/guides/results/aggregator/samples.py[0]-code / "tenth sample"-prose mismatch (4 figure-of-merit prints + 1 parameter print)
  • autogalaxy_workspace/scripts/guides/results/aggregator/samples_via_aggregator.py — same mismatch
  • autolens_workspace/scripts/guides/results/database/start_here.py:373parameter_lists[9][2]
  • autolens_workspace/scripts/guides/results/aggregator/samples.py:200,219-222[9] × 5
  • autolens_workspace/scripts/guides/results/aggregator/samples_via_aggregator.py:146,178-181[9] × 5
  • autocti_workspace/scripts/dataset_1d/advanced/database/examples/samples.py:103,124-127[9] × 5
  • autocti_workspace/scripts/dataset_1d/results/examples/samples.py:192,211-214[9] × 5

Implementation Steps

  1. Replace each [9] with [-1] and each "tenth sample" prose mention with "final sample" (inner parameter indexes [2]/[3] unchanged).
  2. In the two autogalaxy aggregator guides, change the part-fixed [0] prints to [-1] and correct the prose.
  3. Notebook twins left to release-time regeneration per workspace convention.
  4. Suggested branch (all repos): feature/tenth-sample-hardcoded-index.

Validation

  • autocti: PYAUTO_TEST_MODE=1 run of database/start_here.pydatabase/examples/samples.py and results chain — crashes at [9] before, must pass after.
  • autofit: smoke cookbooks/result.py.
  • autolens/autogalaxy: targeted run_smoke.run_script on the touched guides (real_search outputs from 2026-08-19 validation allow fast resume).

Original Prompt

Click to expand starting prompt

Bug in the workspaces: tutorial scripts hardcode stored-sample index 9 and crash under low-sample profiles. autocti_workspace scripts/dataset_1d/advanced/database/examples/samples.py:103 prints samples.parameter_lists[9][2]; autolens_workspace scripts/guides/results/aggregator/samples.py:200 and samples_via_aggregator.py:146 print samples.parameter_lists[9]. Any stored run with fewer than 10 samples (e.g. test-mode fake searches) raises IndexError; real-search runs pass, so this is latent in CI but breaks local/test-mode validation sweeps (found 2026-08-19). Fix: derive the index from len(samples.parameter_lists) or guard it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions