Skip to content

fix(interpolator): add missing test for empty-instances guard; clear two stale NEEDS_FIX markers #1411

Description

@Jammy2211

Summary

Two NEEDS_FIX markers filed 2026-04-10 blame an IndexError in
InstanceInterpolator.__getitem__ when querying a between-samples time (1.5).
Both markers are stale. The underlying library bug was fixed by
PyAutoFit c8511b553 (2026-04-12) — two days after the markers were filed —
which added the empty-instances guard in autofit/interpolator/abstract.py.

Reproduction on clean main (2026-07-22)

All three repos clean and on main, with output/ moved aside so nothing was
served from cache:

Run Result
autofit_workspace scripts/features/interpolate.py, real, fresh output/ exit 0
same script under PYAUTO_TEST_MODE=1, no output/ at all exit 0
HowToFit chapter_1_introduction/tutorial_5_results_and_samples.py, real exit 0

Corrections to the original diagnosis

  • It is not a bracketing / off-by-one bug. t == 1.5 interpolation always
    worked — test_interpolator.py already exercises between-samples queries at
    1.5 in four places. The real failure was an empty instances list reaching
    self.instances[0], as the workspace marker's own text said ("value_map
    lookup falls through to empty instances list").
  • HowToFit tutorial_5 contains no interpolator code at all. The "likely
    related to InstanceInterpolator" text in that marker was a misattribution.

Residual gap

c8511b553 shipped the guard with no test. That is the only code change
left to make.

Plan (high level)

  1. Add the missing regression test for the empty-instances guard in PyAutoFit.
  2. Remove the stale NEEDS_FIX marker from autofit_workspace no_run.yaml.
  3. Remove the stale NEEDS_FIX marker from HowToFit no_run.yaml.
  4. Record here that the fix was c8511b553 and that the HowToFit marker's
    stated cause was never correct.

Plan (detailed)

  • PyAutoFit/test_autofit/interpolator/test_interpolator.py — add
    test_empty_instances_raises: construct af.LinearInterpolator([]), query
    interpolator.t == 1.5, assert pytest.raises(IndexError, match="no instances").
    numpy-only, no JAX. Verify with pytest test_autofit/interpolator/.
  • autofit_workspace/config/build/no_run.yaml — delete the
    features/interpolate line.
  • HowToFit/config/build/no_run.yaml — delete the
    chapter_1_introduction/tutorial_5_results_and_samples line.
  • No notebook regeneration — config-only change in both workspaces.

Branch: feature/interpolator-stale-needs-fix

Out of scope (to be filed separately)

Two exit-0 correctness smells noticed while reproducing, unrelated to the
IndexError:

  • HowToFit tutorial_5: the section printing "only the Gaussian normalization
    and sigma" emits 5 values instead of 2.
  • autofit_workspace features/interpolate: the aggregator block prints a
    different t=2 centre than the in-memory block (49.96 vs 59.73 in one run).

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