Skip to content

refactor(light): split multipole module + add ag.lp_linear variants#421

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/multipole-light-profiles-linear
May 18, 2026
Merged

refactor(light): split multipole module + add ag.lp_linear variants#421
Jammy2211 merged 1 commit into
mainfrom
feature/multipole-light-profiles-linear

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #420.

  1. Refactor: splits autogalaxy/profiles/light/standard/multipole.py into per-class modules (sersic_multipole.py, gaussian_multipole.py) with a shared private mixin in _multipole_mixin.py. Tests split correspondingly. Pure mechanical refactor — no behaviour change.
  2. New: adds ag.lp_linear.SersicMultipole and ag.lp_linear.GaussianMultipole — the linear-inversion counterparts of the standard variants. Each subclasses its standard counterpart + LightProfileLinear, hardcoding intensity=1.0 (the inversion solves it). Docs autosummary updated under the Linear [ag.lp_linear] section.

895 unit tests pass (10 new tests cover the linear variants and the split standard tests; previously 885 in main).

API Changes

Two new public classes added to ag.lp_linear:

  • ag.lp_linear.SersicMultipole — linear elliptical Sersic with m=3/m=4 multipole perturbations
  • ag.lp_linear.GaussianMultipole — linear elliptical Gaussian with m=3/m=4 multipole perturbations

Standard classes (ag.lp.SersicMultipole / ag.lp.GaussianMultipole) move from multipole.py to sersic_multipole.py / gaussian_multipole.py — import paths via ag.lp.* are unchanged.

See full details below.

Test Plan

  • python -m pytest test_autogalaxy/profiles/light/standard/test_sersic_multipole.py test_autogalaxy/profiles/light/standard/test_gaussian_multipole.py — 12 tests pass (split intact from feat(light): add SersicMultipole and GaussianMultipole profiles #420)
  • python -m pytest test_autogalaxy/profiles/light/linear/test_sersic_multipole.py test_autogalaxy/profiles/light/linear/test_gaussian_multipole.py — 10 new tests pass
  • python -m pytest test_autogalaxy/ — 895 pass, no regressions
  • ag.lp_linear.SersicMultipole and ag.lp_linear.GaussianMultipole resolve via the standard ag.lp_linear.* namespace
  • Smoke-checked: linear variant intensity is 1.0, constructor rejects intensity= kwarg, multipole tuples propagate through to the image computation
  • JAX path validated in companion workspace_test PRs (see Coordination below)
Full API Changes (for automation & release notes)

Added

  • ag.lp_linear.SersicMultipole(centre, ell_comps, effective_radius, sersic_index, multipole_3_comps=(0.0, 0.0), multipole_4_comps=(0.0, 0.0)) — linear-inversion counterpart of ag.lp.SersicMultipole. Inherits from both ag.lp.SersicMultipole and LightProfileLinear, so isinstance(profile, ag.lp.SersicMultipole) and isinstance(profile, LightProfileLinear) are both true.
  • ag.lp_linear.GaussianMultipole(centre, ell_comps, sigma, multipole_3_comps=(0.0, 0.0), multipole_4_comps=(0.0, 0.0)) — same for Gaussian.
  • autogalaxy.profiles.light.standard._multipole_mixin._LightProfileMultipoleMixin — internal mixin module extracted from the old multipole.py. Leading underscore signals throwaway scaffolding.

Removed

  • autogalaxy.profiles.light.standard.multipole module — split into sersic_multipole + gaussian_multipole + _multipole_mixin. The public ag.lp.SersicMultipole and ag.lp.GaussianMultipole import paths are unchanged.

Renamed / Moved

  • autogalaxy.profiles.light.standard.multipole.SersicMultipoleautogalaxy.profiles.light.standard.sersic_multipole.SersicMultipole (public ag.lp.SersicMultipole path unchanged).
  • autogalaxy.profiles.light.standard.multipole.GaussianMultipoleautogalaxy.profiles.light.standard.gaussian_multipole.GaussianMultipole (public ag.lp.GaussianMultipole path unchanged).

Changed Signature

  • None for existing classes. New ag.lp_linear variants intentionally drop the intensity constructor argument (constructor raises TypeError if passed), mirroring the standard linear pattern.

Changed Behaviour

  • None — existing ag.lp.SersicMultipole / ag.lp.GaussianMultipole behaviour unchanged.

Migration

  • Direct imports of from autogalaxy.profiles.light.standard.multipole import SersicMultipole need to switch to from autogalaxy.profiles.light.standard.sersic_multipole import SersicMultipole. The public import autogalaxy as ag; ag.lp.SersicMultipole path keeps working unchanged.

Coordination

This PR is part of a 3-PR follow-up to #418:

  • This PR (PyAutoGalaxy) — adds linear variants + refactor + Linear docs.
  • autogalaxy_workspace_test — adds scripts/jax_likelihood_functions/light_multipole/multipole.py that exercises ag.lp.SersicMultipole under fitness._vmap + jax.jit(analysis.fit_from). Must merge AFTER this PR (depends on the new classes).
  • autolens_workspace_test — adds scripts/jax_likelihood_functions/light_multipole/multipole.py for the strong-lens case (lens bulge = al.lp_linear.SersicMultipole). Must merge AFTER this PR (depends on the new linear class).

🤖 Generated with Claude Code

Refactors the multipole light profile module added in #420:

- autogalaxy/profiles/light/standard/multipole.py is split into per-class
  modules:
  - _multipole_mixin.py — private, holds the shared
    _LightProfileMultipoleMixin
  - sersic_multipole.py — SersicMultipole
  - gaussian_multipole.py — GaussianMultipole
- test_autogalaxy/profiles/light/standard/test_multipole.py is split into
  test_sersic_multipole.py + test_gaussian_multipole.py
- standard/__init__.py updated to the two new imports

Adds linear-light-profile counterparts:

- autogalaxy/profiles/light/linear/sersic_multipole.py
  ag.lp_linear.SersicMultipole(lp.SersicMultipole, LightProfileLinear)
  hardcodes intensity=1.0 (solved via inversion) and drops intensity from
  the constructor signature.
- autogalaxy/profiles/light/linear/gaussian_multipole.py — same pattern.
- linear/__init__.py exports both.
- test_autogalaxy/profiles/light/linear/test_sersic_multipole.py and
  test_gaussian_multipole.py cover: class identity (LightProfileLinear +
  the standard subclass), intensity-not-a-constructor-parameter,
  multipole_*_comps propagation, parity with the linear base profile at
  zero perturbation, and image parity with the standard variant at
  intensity=1.0.

Docs:
- docs/api/light.rst Linear [ag.lp_linear] section now lists
  SersicMultipole and GaussianMultipole.

895 unit tests pass. Follows up #418.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 18, 2026
@Jammy2211 Jammy2211 merged commit 24b7160 into main May 18, 2026
6 checks passed
@Jammy2211 Jammy2211 deleted the feature/multipole-light-profiles-linear branch May 18, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant