feat(AnalysisImaging): plumb dataset_model into adapt_images_via_instance_from#512
Merged
Merged
Conversation
…ance_from Threads the per-iteration dataset_model and xp backend into adapt_images_via_instance_from so AdaptImages can rotate its cached image-plane mesh grid alongside the data grid for multi-band fits. Adds 3 chi^2=0 simulate-and-fit tests in test_simulate_and_fit_imaging.py exercising the full lensing chain (Tracer + DatasetModel rotation): offset-only, rotated mass, and combined offset+rotation. Refs PyAutoLens#511, PyAutoArray#312, PyAutoGalaxy#416. 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
AnalysisImaging.fit_fromnow passes the per-iterationdataset_modelandself._xpthroughadapt_images_via_instance_from, so adaptive pixelization mesh grids stay in the same rotated/shifted frame as the data grid in multi-band fits.This is the small but load-bearing PyAutoLens-side change to complete the multi-band grid-rotation feature. Adds 3
chi^2 = 0simulate-and-fit regression tests at the full lensing chain (Tracer + DatasetModel rotation).Depends on
PyAutoArray#312 and PyAutoGalaxy#416 (the latter is what defines the new
dataset_modelkwarg onAnalysisDataset.adapt_images_via_instance_from). CI will be red on this PR until both merge.Scripts Changed
None beyond the test file.
Test plan
python -m pytest test_autolens/— 277 tests pass on this branchtest_simulate_and_fit_imaging.pycovering the strong-lens use case (Hannah's actual JWST scenario):test__perfect_fit__sim_offset_lens_and_source__fit_with_dataset_model_grid_offset__chi_squared_zerotest__perfect_fit__sim_rotated_lens_mass__fit_with_dataset_model_grid_rotation__chi_squared_zerotest__perfect_fit__sim_offset_and_rotated_lens__fit_with_dataset_model_offset_and_rotation__chi_squared_zeroEach one simulates a strong-lens system with shifted/rotated mass and source profiles, fits with identity-frame profiles + matching
DatasetModelparameters, and assertschi_squared = pytest.approx(0.0, abs=1e-4).Refs PyAutoLens#511.