From a7d129e1b06608894949f20d7f84b9088442947d Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Fri, 1 May 2026 09:22:49 +0100 Subject: [PATCH] fix: xp-gate jax.scipy.special.factorial in shapelets/exponential.py The unconditional `from jax.scipy.special import factorial` inside ShapeletExponential.image_2d_from broke library CI with ModuleNotFoundError when JAX is absent. Sibling modules cartesian.py and polar.py already gate this import with `if xp is np`; this applies the same pattern to exponential.py. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../profiles/light/standard/shapelets/exponential.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/autogalaxy/profiles/light/standard/shapelets/exponential.py b/autogalaxy/profiles/light/standard/shapelets/exponential.py index 02d1cf0f..fa80a4b2 100644 --- a/autogalaxy/profiles/light/standard/shapelets/exponential.py +++ b/autogalaxy/profiles/light/standard/shapelets/exponential.py @@ -87,7 +87,12 @@ def image_2d_from( The image of the Exponential Shapelet evaluated at every (y,x) coordinate on the transformed grid. """ from scipy.special import genlaguerre - from jax.scipy.special import factorial + + # factorial backend switch + if xp is np: + from scipy.special import factorial + else: + from jax.scipy.special import factorial radial = (grid.array[:, 0] ** 2 + grid.array[:, 1] ** 2) / self.beta theta = xp.arctan(grid.array[:, 1] / grid.array[:, 0])