Skip to content

fix(interpolate): select instances by time, not list position#104

Merged
Jammy2211 merged 1 commit into
mainfrom
fix/interpolate-instance-labels
Jul 22, 2026
Merged

fix(interpolate): select instances by time, not list position#104
Jammy2211 merged 1 commit into
mainfrom
fix/interpolate-instance-labels

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Found while clearing this script's stale NEEDS_FIX marker (PyAutoLabs/PyAutoFit#1411). Script always exited 0 and the interpolation was always correct — these are labelling bugs that made the tutorial's headline claim unverifiable.

1. Off-by-one in the labels (both blocks)

ml_instances_list[0] is the t=0 fit and [1] is t=1 — the list is built by for time in range(3). Both blocks labelled them fit 1 (t = 1) and fit 2 (t = 2). The prose then invited the reader to bracket the interpolated t=1.5 centre between two numbers that were actually the t=0 and t=1 fits, so the check demonstrated nothing.

2. The aggregator does not return fit order

Verified against a real output/interpolate:

time centre
0 40.049
2 59.731
1 49.963

That is why the aggregator block printed a different "fit 2" (59.73) than the in-memory block (49.96) for the same three fits — presented without comment, as if the round-trip changed the result.

Fix

Both blocks now select via a small instance_at_time() helper, so position can never drift from time again, and the prose explains that aggregator ordering is not guaranteed to be fit order (a genuinely useful lesson here).

Interpolation was never affected — _value_map keys by time and sorts internally. After the fix both blocks print identical values and 54.834 visibly brackets between 49.96 and 59.73, making the script's "close to 55.0" claim demonstrable.

Verified: exit 0, real run. Notebook regenerated.

🤖 Generated with Claude Code

Two compounding label bugs made the tutorial's headline claim
unverifiable, though the interpolation itself was always correct.

1. Off-by-one: ml_instances_list[0] is the t=0 fit and [1] is t=1 (the
   list is built by 'for time in range(3)'), but both print blocks
   labelled them 'fit 1 (t = 1)' and 'fit 2 (t = 2)'. The reader was
   invited to bracket the interpolated t=1.5 value between two numbers
   that were actually the t=0 and t=1 fits.

2. The aggregator does not return fit order — verified against a real
   output directory it loads t=0, t=2, t=1. So the aggregator block
   printed a different 'fit 2' value than the in-memory block (49.96 vs
   59.73) for the same three fits, presented without comment as if the
   round-trip had changed the result.

Both blocks now select via instance_at_time() and print identical
values, and the prose explains that aggregator order is not fit order.

Interpolation was never affected: _value_map keys by the time attribute
and sorts, so the t=1.5 result (54.834) was correct throughout. It now
visibly brackets between 49.96 and 59.73, making the script's 'close to
55.0' claim actually demonstrable.

Verified: exit 0. Notebook regenerated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Jammy2211
Jammy2211 merged commit 2758dfe into main Jul 22, 2026
8 checks passed
@Jammy2211
Jammy2211 deleted the fix/interpolate-instance-labels branch July 22, 2026 09:32
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