fix: restore missing source assignment in subhalo_refine (Cluster F)#133
Merged
fix: restore missing source assignment in subhalo_refine (Cluster F)#133
Conversation
scripts/group/features/advanced/subhalo/detect/start_here.py crashed with `NameError: name 'source' is not defined` at line 634 (`source= source` kwarg in `af.Collection`) inside the `subhalo_refine` function. Root cause: PR #117 ("Cluster F triage") removed the `"source": ...` key from five lens_dict literals in this file because they collided with the explicit `source=source` kwarg on the matching `af.Collection(...)` call. For four of the five functions, a local `source = ...` assignment already existed earlier in the function body, so removing the lens_dict entry left the explicit kwarg resolvable. `subhalo_refine` was the exception: PR #117 removed `"source": subhalo_grid_search_result.model.galaxies.source` from its lens_dict but did not lift that expression into a standalone `source = ...` assignment, leaving the explicit kwarg pointing at an undefined name. Add the missing standalone assignment, restoring exactly the value PR #117 dropped. Behavior matches the pre-PR-#117 model (the grid-search posterior source flows into the refine search) and the style matches every other function in this file. Verified locally: pre-fix exits 1 with NameError at line 634 under fast smoke env; post-fix exits 0 and subhalo[3]_[single_plane_refine] (the previously-failing search phase) completes successfully. 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
scripts/group/features/advanced/subhalo/detect/start_here.pycrashed withNameError: name 'source' is not defined. Did you mean: 'source_lp'?at line 634 (thesource=sourcekwarg in theaf.Collection(...)call insidesubhalo_refine).This was Cluster F of the recent release-prep triage — fallout from PR #117 ("Cluster F triage: 4 script fixes", merged 2026-05-02). PR #117 removed the redundant
"source": ...key from fivelens_dictliterals in this file (they collided with the explicitsource=sourcekwarg, causingTypeError: got multiple values). For four functions, a localsource = ...assignment already existed earlier in the function body, so the explicit kwarg remained resolvable.subhalo_refinewas the exception — PR #117 dropped"source": subhalo_grid_search_result.model.galaxies.sourcefrom its lens_dict without lifting that expression into a standalone assignment, leaving the explicit kwarg pointing at an undefined name.Note: Python's
Did you mean: 'source_lp'?hint is a lexical-proximity suggestion only.source_lp(line 72) is a function in this file, not a Galaxy/Model — passing it as a Galaxy kwarg would have type-errored at fit time. The right fix is to restore the value PR #117 actually dropped.Scripts Changed
scripts/group/features/advanced/subhalo/detect/start_here.py— functionsubhalo_refine. Add a single linesource = subhalo_grid_search_result.model.galaxies.sourcebetween the existingsubhalo.mass.redshift_object = subhalo.redshift(line 624) and thelens_dict = {literal (line 626). Restores exactly the value PR Cluster F triage: 4 script fixes (items 2, 3, 5, 9) #117 dropped, matches the standalone-assignment style every other function in this file uses forsource, and produces a model identical to the pre-PR-Cluster F triage: 4 script fixes (items 2, 3, 5, 9) #117 behavior.Test Plan
PYAUTO_TEST_MODE=2 PYAUTO_SKIP_FIT_OUTPUT=1 PYAUTO_SKIP_VISUALIZATION=1 PYAUTO_SKIP_CHECKS=1 PYAUTO_SMALL_DATASETS=1 PYAUTO_FAST_PLOTS=1— script exits 0 andsubhalo[3]_[single_plane_refine](the previously-failing phase) completes successfully. Pre-fix: exits 1 with the documentedNameErrorat line 634.🤖 Generated with Claude Code