@@ -18,6 +18,7 @@ def solve(
1818 tracer : OperateDeflections ,
1919 source_plane_coordinate : Tuple [float , float ],
2020 plane_redshift : Optional [float ] = None ,
21+ remove_infinities : bool = True ,
2122 ) -> aa .Grid2DIrregular :
2223 """
2324 Solve for the image plane coordinates that are traced to the source plane coordinate.
@@ -26,9 +27,15 @@ def solve(
2627 within the triangle. The triangles are sub-sampled to increase the resolution with only the triangles that
2728 contain the source plane coordinate and their neighbours being kept.
2829
29- The means of the triangles are then filtered to keep only those with an absolute magnification above the
30+ The means of the triangles are then filtered to keep only those with an absolute magnification above the
3031 threshold.
3132
33+ The positions are stored on an array of fixed shape defined by `MAX_CONTAINING_SIZE`. This ensures the
34+ array is static, which is important for JAX compatibility. This array typically has many entries
35+ which use the sentinel value of `inf`, subsequent JAX calculations incorporated. By default, these
36+ sentinel values are removed from the output, for example general use outside of JAX when simulating
37+ strong lenses.
38+
3239 Parameters
3340 ----------
3441 source_plane_coordinate
@@ -59,4 +66,8 @@ def solve(
5966 sentinel = self ._xp .full_like (solution [0 ], fill_value = self ._xp .inf )
6067 solution = self ._xp .where (is_nan [:, None ], sentinel , solution )
6168
69+ if remove_infinities :
70+
71+ solution = solution [~ self ._xp .isinf (solution ).any (axis = 1 )]
72+
6273 return aa .Grid2DIrregular (solution )
0 commit comments