Fix mapper-index lookup in source_plane_inversion_centre_from#491
Merged
Fix mapper-index lookup in source_plane_inversion_centre_from#491
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IndexErrorinResult.source_plane_inversion_centre_fromwhen only some planes have pixelizationsplane_indexes_with_pixelizationsis a list of plane indices in mapper order, so the mapper for a given plane is found via.index(plane_index), not[plane_index][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.pyruns to completion underPYAUTO_TEST_MODE=2test_autolens/to confirm no regressionWhy now
Surfaced by triage Cluster F item 4 —
autolens_workspace/scripts/imaging/features/advanced/double_einstein_ring/slam.pyraised a genericaf.exc.FitExceptionbecauseanalysis.py:84swallows the underlying exception. Wrapping with a debug shim revealedIndexError: list index out of rangeatresult.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 raisesIndexErrorwhen only some planes have a pixelization. Previously raised whenplane_indexes_with_pixelizationshad 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