fix: drop AdaptImages single-pixelated-galaxy fallback in lens.to_inversion#474
Merged
Conversation
…ersion Replaces the autolens/lens/to_inversion.py:280-290 workaround (search dict keys for has(cls=Pixelization) when galaxies_with_pixelization_list has length 1) with the new AdaptImages.image_for_galaxy helper from PyAutoGalaxy. Per-plane GalaxiesToInversion now passes path_galaxies=tracer.galaxies so the autogalaxy-side positional lookup sees the full galaxy list rather than a per-plane subset. Analysis. fit_from passes galaxies=tracer.galaxies into adapt_images_via_instance_from. Depends on PyAutoGalaxy PR (image_for_galaxy + path_galaxies). Merge order: PyAutoGalaxy first. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Workspace PR: PyAutoLabs/autogalaxy_workspace_test#12 |
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
Replaces the fragile single-pixelated-galaxy fallback in
autolens/lens/to_inversion.pywith the newAdaptImages.image_for_galaxyhelper from PyAutoGalaxy. The fallback (lines 280-290) was a workaround for the samejax.jit-unflatten Galaxy-identity issue: when a fit had exactly one pixelization, it picked the only entry ingalaxy_image_dictbyhas(cls=Pixelization). That covers the common single-source case but is incorrect once a fit has multiple pixelizations.The new helper looks up adapt images by path-tuple via
tracer.galaxiesordering, which is stable across the JIT boundary. Per-planeGalaxiesToInversionconstructions inimage_plane_mesh_grid_pg_listnow passpath_galaxies=self.tracer.galaxiesso the autogalaxy-side helper sees the full list (the per-plane subset would otherwise misalign withgalaxy_path_list).Depends on PyAutoLabs/PyAutoGalaxy#370, which introduces
image_for_galaxyand thepath_galaxiesconstructor argument onGalaxiesToInversion. Merge order: PyAutoGalaxy first.API Changes
Analysis.fit_from(imaging + interferometer) passesgalaxies=tracer.galaxiesintoadapt_images_via_instance_from. No public symbols added or removed in autolens. Internal change. See full details below.Test Plan
test_autolens/suite remains green (256 pass locally).jax_likelihood_functions/imaging/{rectangular,rectangular_mge,delaunay,delaunay_mge}.pyto confirm the fallback removal doesn't regress single-pixelization fits.Full API Changes (for automation & release notes)
Removed
autolens/lens/to_inversion.py:280-290. The pattern (search dict keys forhas(cls=Pixelization)and grab[0]whenlen(galaxies_with_pixelization_list) == 1) is replaced by the path-tuple lookup inAdaptImages.image_for_galaxy.Changed Behaviour
TracerToInversion.adapt_galaxy_image_pg_listresolves adapt images viaimage_for_galaxy(galaxy, self.tracer.galaxies)for all pixelization counts, not only the single-pixelization case.TracerToInversion.image_plane_mesh_grid_pg_listconstructs per-planeGalaxiesToInversioninstances withpath_galaxies=self.tracer.galaxiesso the autogalaxy helper's positional lookup aligns with the full galaxy list rather than the per-plane subset.Migration
Analysis.fit_fromsignatures unchanged.🤖 Generated with Claude Code