Skip to content

fix: restore missing source assignment in subhalo_refine (Cluster F)#133

Merged
Jammy2211 merged 1 commit intomainfrom
feature/subhalo-refine-source-fix
May 7, 2026
Merged

fix: restore missing source assignment in subhalo_refine (Cluster F)#133
Jammy2211 merged 1 commit intomainfrom
feature/subhalo-refine-source-fix

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

scripts/group/features/advanced/subhalo/detect/start_here.py crashed with NameError: name 'source' is not defined. Did you mean: 'source_lp'? at line 634 (the source=source kwarg in the af.Collection(...) call inside subhalo_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 five lens_dict literals in this file (they collided with the explicit source=source kwarg, causing TypeError: got multiple values). For four functions, a local source = ... assignment already existed earlier in the function body, so the explicit kwarg remained resolvable. subhalo_refine was the exception — PR #117 dropped "source": subhalo_grid_search_result.model.galaxies.source from 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 — function subhalo_refine. Add a single line source = subhalo_grid_search_result.model.galaxies.source between the existing subhalo.mass.redshift_object = subhalo.redshift (line 624) and the lens_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 for source, and produces a model identical to the pre-PR-Cluster F triage: 4 script fixes (items 2, 3, 5, 9) #117 behavior.

Test Plan

  • Smoke tests pass for autolens_workspace
  • Verified locally under 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 and subhalo[3]_[single_plane_refine] (the previously-failing phase) completes successfully. Pre-fix: exits 1 with the documented NameError at line 634.

🤖 Generated with Claude Code

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>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 7, 2026
@Jammy2211 Jammy2211 merged commit 32b4e60 into main May 7, 2026
5 checks passed
@Jammy2211 Jammy2211 deleted the feature/subhalo-refine-source-fix branch May 7, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant