Skip to content

Fix mapper-index lookup in source_plane_inversion_centre_from - #491

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/cluster-f-api-drift
May 2, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/cluster-f-api-drift

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

  • Fix IndexError in Result.source_plane_inversion_centre_from when only some planes have pixelizations
  • Indexing semantics: plane_indexes_with_pixelizations is a list of plane indices in mapper order, so the mapper for a given plane is found via .index(plane_index), not [plane_index]
  • The previous code only worked when every plane was pixelized (the identity case [0,1,...].index(i) == [0,1,...][i])

API Changes

None — internal changes only.
See full details below.

Test Plan

  • pytest test_autolens/analysis/ — 28 passed (3.5s, run by Opus before delegation)
  • autolens_workspace/scripts/imaging/features/advanced/double_einstein_ring/slam.py runs to completion under PYAUTO_TEST_MODE=2
  • Subagent re-runs full test_autolens/ to confirm no regression

Why now

Surfaced by triage Cluster F item 4 — autolens_workspace/scripts/imaging/features/advanced/double_einstein_ring/slam.py raised a generic af.exc.FitException because analysis.py:84 swallows the underlying exception. Wrapping with a debug shim revealed IndexError: list index out of range at result.py:445.

Full API Changes (for automation & release notes)

Removed

None.

Added

None.

Changed Behaviour

  • Result.source_plane_inversion_centre_from(plane_redshift=...) no longer raises IndexError when only some planes have a pixelization. Previously raised when plane_indexes_with_pixelizations had fewer entries than the plane index of the source. Now correctly looks up the mapper index via .index().

Migration

None required.

🤖 Generated with Claude Code

`plane_indexes_with_pixelizations` returns a list of plane indices that
have a pixelization, in mapper order — e.g. [1] when only the source
plane (plane 1) has a pixelization. The previous code at result.py:445
indexed that list by plane index (`[plane_index]`) instead of looking up
the position of the plane index within the list (`.index(plane_index)`).

For a single-source pixelized fit, plane_indexes_with_pixelizations=[1]
and plane_index=1 raises `IndexError: list index out of range`. This
surfaced as a swallowed FitException via analysis.py:84 in the
`double_einstein_ring/slam.py` workspace tutorial.

Widen `except TypeError` to `except (TypeError, ValueError)` so an
unknown plane_index falls back to mapper_index=0.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 2, 2026
@Jammy2211
Jammy2211 merged commit c2a9f57 into main May 2, 2026
5 checks passed
@Jammy2211
Jammy2211 deleted the feature/cluster-f-api-drift branch May 2, 2026 17:13
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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