Skip to content

Feature/deflections operate jax#391

Merged
Jammy2211 merged 4 commits intomainfrom
feature/deflections_operate_jax
Mar 4, 2026
Merged

Feature/deflections operate jax#391
Jammy2211 merged 4 commits intomainfrom
feature/deflections_operate_jax

Conversation

@Jammy2211
Copy link
Owner

This pull request refactors how lensing calculations are performed in the codebase, consolidating operations previously handled by OperateDeflections into a new class, LensCalc. The changes update class inheritance, function signatures, and usages throughout the codebase and tests to use LensCalc for lensing calculations such as magnification and deflections. Additionally, the pull request simplifies and clarifies the handling of multi-plane lensing and updates test fixtures and expectations accordingly.

Refactoring and API changes:

  • Replaced OperateDeflections with LensCalc across the codebase, including imports, class inheritance, and function signatures [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12].
  • Updated usage of lensing calculations to use LensCalc methods, including in tracer_util.py, point fitting, and solver logic [1] [2] [3] [4].

Multi-plane lensing and magnification:

  • Refactored multi-plane magnification calculations to use LensCalc.from_tracer with explicit use_multi_plane and plane_j arguments, removing the confusing deflections_func property and related logic [1] [2] [3] [4].
  • Simplified mock and test tracer classes, removing unused or redundant methods and updating logic to match the new calculation flow [1] [2] [3] [4] [5].

Test and fixture updates:

  • Updated tests and fixtures to use the new LensCalc-based API, including changes to expected results due to the refactor and improvements in calculation accuracy [1] [2] [3] [4] [5].
  • Adjusted test assertions and mock objects to align with the updated calculation logic and expected outputs.

Cleanup and documentation:

  • Removed unused imports and properties, and updated documentation references to reflect the new LensCalc class [1] [2] [3].

These changes modernize and clarify the codebase's approach to lensing calculations, making the API more explicit and maintainable.

Jammy2211 and others added 4 commits March 2, 2026 21:40
- Remove ag.OperateDeflections from Tracer inheritance (tracer.py)
- Update abstract.py: magnifications_at_positions uses OperateDeflections.from_tracer
  (removes deflections_func property; multi-plane selection is done inside from_tracer)
- Update shape_solver.py and point_solver.py: type annotations use Tracer;
  _filter_low_magnification uses OperateDeflections.from_mass_obj(tracer)
- Clean up NullTracer in mock.py (remove dead magnification_2d_via_hessian_from override)
- Fix MockTracerPoint.deflections_yx_2d_from signature (grid, xp=np) and remove
  dead magnification_2d_via_hessian_from override (mock_tracer.py)
- Update tests to new composition API; assertion numerical values left for manual update

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Update import in autolens/__init__.py
- tracer_util.py uses ag.LensCalc.from_mass_obj for fermat_potential_from
- Update point/fit/abstract.py and point/solver/shape_solver.py
- Update tests and docs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jammy2211 Jammy2211 merged commit 8e973d4 into main Mar 4, 2026
0 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant