Skip to content

fix: make circular ell_comps image gradients finite - #571

Merged
Jammy2211 merged 2 commits into
mainfrom
fix/circular-ell-comps-image-gradient
Aug 14, 2026
Merged

fix: make circular ell_comps image gradients finite#571
Jammy2211 merged 2 commits into
mainfrom
fix/circular-ell-comps-image-gradient

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

  • evaluate Sersic eccentric radii directly from Cartesian ell_comps, avoiding the undefined polar angle derivative at (0, 0)
  • preserve the existing fac <= 0.999 clamp and transformed-grid compatibility
  • add NumPy parity coverage for circular, anisotropic, rotated, and near-clamped profiles

Closes #570.

Why

The profiling hazard likelihood.imaging-sersic.ell-comps-origin-nonfinite-gradient showed a finite off-centre Sersic image and complete FitImaging likelihood at the circular point, but a [NaN, NaN] JAX gradient. The sampled parameters are Cartesian ell_comps_0/1; converting them to axis ratio and angle introduces an avoidable polar singularity.

The new radius identity remains in Cartesian coordinates:

r_ecc^2 =
  ((1 + f^2 - 2 e_x) x^2 - 4 e_y x y + (1 + f^2 + 2 e_x) y^2)
  / (1 - f^2)

where f^2=e_y^2+e_x^2 after the existing magnitude clamp.

Validation

  • focused current Sersic tests: 8 passed
  • NumPy direct/legacy image parity: maximum absolute difference 1.46e-15 across circular, anisotropic, rotated, and near-clamped cases
  • downstream JAX jit(grad) image probe at ell_comps=(0, 0): finite; central differences at 1e-4, 1e-5, and 1e-6 agree
  • downstream full FitImaging likelihood: value unchanged at -15.477240141252718; origin gradient now finite at [1.1569945714414, -0.5449763942867472]; all ±1e-8 and ±1e-6 neighbourhood gradients finite
  • formatting check and compile check passed
  • JAX validation is downstream rather than in PyAutoGalaxy unit tests, per repository policy

No public API, prior, configuration, or release change.

@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Aug 14, 2026 — with ChatGPT Codex Connector
@Jammy2211
Jammy2211 merged commit fe41d21 into main Aug 14, 2026
3 checks passed
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.

fix: make circular ell_comps image gradients finite

1 participant