Skip to content

Commit 35d9505

Browse files
Jammy2211claude
authored andcommitted
feat: thread xp through Grid2DIrregular.grid_2d_via_deflection_grid_from
Removes the known JAX-jit blocker for the PyAutoLens point-source source-plane fit path (PyAutoLabs/PyAutoLens#657, phase 2). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 5c7a5e0 commit 35d9505

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

autoarray/structures/grids/irregular_2d.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def extent_with_buffer_from(self, buffer: float = 1.0e-8) -> List[float]:
168168
]
169169

170170
def grid_2d_via_deflection_grid_from(
171-
self, deflection_grid: np.ndarray
171+
self, deflection_grid: np.ndarray, xp=np
172172
) -> "Grid2DIrregular":
173173
"""
174174
Returns a new Grid2DIrregular from this grid coordinates, where the (y,x) coordinates of this grid have a
@@ -181,8 +181,13 @@ def grid_2d_via_deflection_grid_from(
181181
----------
182182
deflection_grid
183183
The grid of (y,x) coordinates which is subtracted from this grid.
184+
xp
185+
The array module (``numpy`` or ``jax.numpy``) used to construct the returned grid, mirroring
186+
``subtracted_from`` / ``subtracted_and_rotated_from``. Passed through explicitly by the caller rather
187+
than inferred from ``self._xp``, so JIT-traced call sites (where ``self`` may not carry a reliable
188+
``use_jax`` flag) do not silently fall back to NumPy.
184189
"""
185-
return Grid2DIrregular(values=self - deflection_grid, xp=self._xp)
190+
return Grid2DIrregular(values=self.array - xp.asarray(deflection_grid), xp=xp)
186191

187192
def squared_distances_to_coordinate_from(
188193
self, coordinate: Tuple[float, float] = (0.0, 0.0)

0 commit comments

Comments
 (0)