Conversation
…iles Move slow scipy.integrate.quad-based methods to standalone reference scripts in autolens_workspace_test. The actual deflection calculations already use MGE or CSE decompositions; the integrals were only used for testing. Removed: deflections_2d_via_integral_from, deflection_func from Gaussian, Sersic, SersicGradient, NFW, gNFW, gNFWSph. Removed integral-based potential_2d_from and potential_func from elliptical NFW and gNFW. Removed dead tabulate_integral from AbstractgNFW. Kept gNFW.convergence_func (essential for convergence_2d_from and MGE). Updated comparison tests to use hardcoded expected values instead of calling integral methods. Closes #323 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 task
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace_test#13 |
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
Remove all integral-based deflection and potential methods from mass profiles. These methods used
scipy.integrate.quadand were slow and large — they were only used for testing, since the actual deflection calculations use MGE or CSE decompositions. The integral code is preserved as standalone reference scripts inautolens_workspace_test/scripts/mass_via_integral/.API Changes
The following methods are removed from mass profile classes:
deflections_2d_via_integral_from— removed from Gaussian, Sersic, SersicGradient, NFW, gNFW, gNFWSphdeflection_func— removed from Gaussian, Sersic, SersicGradient, NFW, gNFWpotential_2d_from— removed from elliptical NFW and gNFW (spherical NFWSph analytic version kept)potential_func— removed from NFW and gNFWtabulate_integral— removed from AbstractgNFWdeflection_integrand,deflection_func_sph— removed from gNFWSphgNFW.convergence_funcis kept (essential for convergence and MGE deflections).See full details below.
Test Plan
autolens_workspace_test/scripts/mass_via_integral/verify preserved valuesFull API Changes (for automation & release notes)
Removed
mp.Gaussian.deflections_2d_via_integral_from(grid)— test-only integral deflectionmp.Gaussian.deflection_func(u, y, x, npow, axis_ratio, sigma)— integrand helpermp.Sersic.deflections_2d_via_integral_from(grid)— test-only integral deflectionmp.Sersic.deflection_func(u, y, x, npow, axis_ratio, sersic_index, effective_radius, sersic_constant)— integrand helpermp.SersicGradient.deflections_2d_via_integral_from(grid)— test-only integral deflectionmp.SersicGradient.deflection_func(u, y, x, ...)— integrand helpermp.NFW.deflections_2d_via_integral_from(grid)— test-only integral deflectionmp.NFW.deflection_func(u, y, x, npow, axis_ratio, scale_radius)— integrand helpermp.NFW.potential_2d_from(grid)— integral-based elliptical potentialmp.NFW.potential_func(u, y, x, axis_ratio, kappa_s, scale_radius)— potential integrandmp.gNFW.deflections_2d_via_integral_from(grid, tabulate_bins)— test-only integral deflectionmp.gNFW.deflection_func(u, y, x, ...)— integrand helpermp.gNFW.potential_2d_from(grid, tabulate_bins)— integral-based potentialmp.gNFW.potential_func(u, y, x, ...)— potential integrandmp.gNFWSph.deflections_2d_via_integral_from(grid)— test-only integral deflectionmp.gNFWSph.deflection_integrand(y, eta, inner_slope)— integrand helpermp.gNFWSph.deflection_func_sph(eta)— spherical deflection helperAbstractgNFW.tabulate_integral(grid, tabulate_bins)— dead code after integral removalMigration
Before:
profile.deflections_2d_via_integral_from(grid=grid)— for test comparisonsAfter: Use hardcoded expected values or
deflections_yx_2d_from/deflections_2d_via_cse_from/deflections_2d_via_mge_fromBefore:
nfw.potential_2d_from(grid=grid)on elliptical NFWAfter: Only available on
NFWSph(analytic). Elliptical NFW/gNFW potential raisesNotImplementedError.🤖 Generated with Claude Code