Overview
PR PyAutoLabs/PyAutoGalaxy#324 removed all deflections_2d_via_integral_from methods from PyAutoGalaxy source code, intending to preserve them as standalone reference scripts in scripts/mass_via_integral/. However, only the low-level integrand functions (deflection_func) were copied — the actual scipy.integrate.quad calculation loops were not. The scripts currently call library methods (analytic/CSE/MGE) instead of performing the integral, which defeats their purpose.
This fix adds the integral computation wrappers to each script so they actually compute deflections via numerical integration and compare against the library methods.
Plan
- Add
deflections_2d_via_integral_from(mp, grid) wrapper function to each script, using the profile object's existing transform/utility methods (no reimplementation)
- Update test configs to compute via integral and assert agreement with library methods
- Add missing integrand functions to
gnfw.py and gnfw_virial_mass_conc.py (these were never copied from the PR)
- All integral code is copied verbatim from the removed PR #324 methods
Detailed implementation plan
Affected Repositories
- autolens_workspace_test (primary)
Work Classification
Workspace
Branch Survey
| Repository |
Current Branch |
Dirty? |
| ./autolens_workspace_test |
main |
yes (unrelated dataset/viz changes) |
Suggested branch: feature/deflections-integral-fix
Implementation Steps
- gaussian.py — add
deflections_2d_via_integral_from using existing deflection_func, update 4 configs to compare integral vs deflections_2d_via_analytic_from
- sersic.py — add wrapper, update 2 configs to compare integral vs
deflections_2d_via_cse_from
- sersic_gradient.py — add wrapper, update 2 configs to compare integral vs
deflections_2d_via_cse_from
- nfw.py — add deflection + potential wrappers using existing
nfw_deflection_func/nfw_potential_func, update 4 configs
- gnfw.py — add all missing integral functions (
tabulate_integral, surface_density_integrand, gnfw_deflection_func, gnfw_potential_func, deflection_integrand, deflection_func_sph), add wrappers for elliptical and spherical cases, update all configs
- gnfw_virial_mass_conc.py — add spherical integral functions and wrapper, update config
Key Files
scripts/mass_via_integral/gaussian.py
scripts/mass_via_integral/sersic.py
scripts/mass_via_integral/sersic_gradient.py
scripts/mass_via_integral/nfw.py
scripts/mass_via_integral/gnfw.py
scripts/mass_via_integral/gnfw_virial_mass_conc.py
Original Prompt
Click to expand starting prompt
The followng PR Was meant to move all deflections_via_integral methods out of the source code
and into the @autolens_workspace_test/scripts/mass_via_integral folder:
PyAutoLabs/PyAutoGalaxy#324
The expectation is it would move the functions themselves, including the full calculation, into this folder
so the tests there could use it.
However, it did not move the functions and their calculations themselves from the source code, meaning these tests did not
pass. Can you dig up the PR, look at its history, get the alculations and move them to this test package?
Overview
PR PyAutoLabs/PyAutoGalaxy#324 removed all
deflections_2d_via_integral_frommethods from PyAutoGalaxy source code, intending to preserve them as standalone reference scripts inscripts/mass_via_integral/. However, only the low-level integrand functions (deflection_func) were copied — the actualscipy.integrate.quadcalculation loops were not. The scripts currently call library methods (analytic/CSE/MGE) instead of performing the integral, which defeats their purpose.This fix adds the integral computation wrappers to each script so they actually compute deflections via numerical integration and compare against the library methods.
Plan
deflections_2d_via_integral_from(mp, grid)wrapper function to each script, using the profile object's existing transform/utility methods (no reimplementation)gnfw.pyandgnfw_virial_mass_conc.py(these were never copied from the PR)Detailed implementation plan
Affected Repositories
Work Classification
Workspace
Branch Survey
Suggested branch:
feature/deflections-integral-fixImplementation Steps
deflections_2d_via_integral_fromusing existingdeflection_func, update 4 configs to compare integral vsdeflections_2d_via_analytic_fromdeflections_2d_via_cse_fromdeflections_2d_via_cse_fromnfw_deflection_func/nfw_potential_func, update 4 configstabulate_integral,surface_density_integrand,gnfw_deflection_func,gnfw_potential_func,deflection_integrand,deflection_func_sph), add wrappers for elliptical and spherical cases, update all configsKey Files
scripts/mass_via_integral/gaussian.pyscripts/mass_via_integral/sersic.pyscripts/mass_via_integral/sersic_gradient.pyscripts/mass_via_integral/nfw.pyscripts/mass_via_integral/gnfw.pyscripts/mass_via_integral/gnfw_virial_mass_conc.pyOriginal Prompt
Click to expand starting prompt
The followng PR Was meant to move all deflections_via_integral methods out of the source code
and into the @autolens_workspace_test/scripts/mass_via_integral folder:
PyAutoLabs/PyAutoGalaxy#324
The expectation is it would move the functions themselves, including the full calculation, into this folder
so the tests there could use it.
However, it did not move the functions and their calculations themselves from the source code, meaning these tests did not
pass. Can you dig up the PR, look at its history, get the alculations and move them to this test package?