Repository navigation
feat: fits use the lazy sparse operator; aggregator reapplies setup.json (5C-3a) - #753
Merged
Merged
Conversation
…son, shared setup mixin (5C-3a) AbstractFitInversion.sparse_operator (cached) resolves through dataset.sparse_operator_for(xp, total_mappers > 0, settings); the Galaxy DatasetInterface sites and the interferometer profile-subtraction helpers use it, so the inversion and the dirty-image correction share one operator. Aggregator _imaging_from/_interferometer_from reapply files/setup.json (best-effort). Setup resolution moves into AnalysisSetupMixin. Part of PyAutoLabs/PyAutoLens#885 (likelihood-lifecycle phase 5C-3a). Co-Authored-By: Claude Opus 5.5 <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
Likelihood-lifecycle phase 5C-3a, the first of two PRs under PyAutoLabs/PyAutoLens#885. The PyAutoGalaxy fits now get their sparse operator from one choke point,
AbstractFitInversion.sparse_operator, which callsdataset.sparse_operator_for(xp, needs_operator=total_mappers > 0, settings)(PyAutoArray#712). So a plainFitImaging(dataset, galaxies)uses the lazy operator when the policy is on (aa.Settings(lazy_sparse_operator="auto")orPYAUTO_SETUP=auto; off by default). The interferometer profile-subtraction helpers use the same resolved operator, so the inversion and the dirty-image correction never disagree. Aggregator reloads reapply the search'sfiles/setup.json, and setup resolution moves into one sharedAnalysisSetupMixin.API Changes
AbstractFitInversion.sparse_operatoris now a cached property: the resolved operator (attached → returned whatever the fit; otherwise the lazy one for pixelized numpy fits when the policy is on; else None). It was unused before; the GalaxyDatasetInterfacesites now read it.sparse_profile_terms_from,sparse_dirty_image_from,uses_precomputed_data_term_fromandsparse_chi_squared_fromtake an optionalsparse_operator=(None → the olddataset.sparse_operatorbehaviour, so PyAutoLens callers are unchanged until 5C-3b).agg_util.dataset_with_setup_from(fit, dataset), called by_imaging_from/_interferometer_from: reappliessetup.json(no file → unchanged; array-free → skipped; failure → one warning, reload unapplied).AnalysisSetupMixin(autogalaxy/analysis/analysis/setup.py, no__init__, not onAnalysis);AnalysisDataset(AnalysisSetupMixin, Analysis).setup_util.setup_environment()is public.See full details below.
Test Plan
pytest test_autogalaxy: 1659 passedpytest test_autolenson Lens main against this branch): 1086 passed, 1 xfailedpyauto-heart readiness --dev --repos PyAutoGalaxy): GREEN. Non-blocking shown reasons: the canonical PyAutoFit checkout was 5 commits behind origin (an unrelated Nautilus wall-clock budget, PyAutoFit#1793), so smoke used the older Fit; manifest drift; test run status unknown; no release rehearsal for current source; release push credential check 49 h old.pyauto-heart smoke --affected-by PyAutoGalaxy --jobs 3: 5/5 workspaces PASS against this branch via PYAUTO_ROOT (autogalaxy, autolens_test, euclid, howtolens in the parallel run; autolens failed there with ModuleNotFoundError numpy/yaml during its environment rebuild, the known parallel build race, and passed rerun alone: 42/42 scripts, 2/2 notebooks)Full API Changes (for automation & release notes)
Added
autogalaxy.aggregator.agg_util.dataset_with_setup_from(fit, dataset).autogalaxy.analysis.analysis.setup.AnalysisSetupMixin(_init_setup,setup_key_and_note_from,_apply_resolved_setup,resolve_setup,_log_setup_auto_would_choose,save_setup).autogalaxy.analysis.setup_util.setup_environment().sparse_operator=onsparse_profile_terms_from,sparse_dirty_image_from,uses_precomputed_data_term_fromandsparse_chi_squared_from.Changed
AbstractFitInversion.sparse_operator: now afunctools.cached_propertyresolving throughsparse_operator_for. It returns an attached operator for fits with only linear light profiles, where it used to return None (the property was unused).FitImaging/FitInterferometerpassself.sparse_operatorintoaa.DatasetInterface._imaging_from/_interferometer_fromreapplysetup.json.autogalaxy.analysis.analysis.setup(previously...analysis.dataset).Migration
Notes:
register_instance_pytreeadds everycached_propertyto a fit'sno_flattenset, so JAX treats the cached operator as static, never a pytree child.DatasetInterfaceand interferometer-helper call sites passself.sparse_operator; point/weak adopt the mixin. Until then a Lens fit's inversion stays dense even with the policy on.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code