File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -425,6 +425,22 @@ def image_plane_mesh_grid_list(
425425 except (AttributeError , KeyError , TypeError ):
426426 image_plane_mesh_grid = None
427427
428+ if image_plane_mesh_grid is None :
429+ # Fallback for JAX JIT: after jax.jit unflatten the galaxy instances
430+ # stored as keys in ``adapt_images`` are stale (different Python objects
431+ # from those in the current tracer), so the dict key lookup above fails
432+ # and yields None. When the dict contains exactly one mesh-grid entry,
433+ # take that single value by insertion order — this is always correct in
434+ # the one-pixelised-source case (Delaunay/Hilbert image-mesh fits).
435+ # fit-imaging-pytree-delaunay
436+ try :
437+ dict_ = self .adapt_images .galaxy_image_plane_mesh_grid_dict
438+ vals = list (dict_ .values ()) if dict_ else []
439+ if len (vals ) == 1 :
440+ image_plane_mesh_grid = vals [0 ]
441+ except (AttributeError , TypeError , KeyError ):
442+ pass
443+
428444 image_plane_mesh_grid_list .append (image_plane_mesh_grid )
429445
430446 return image_plane_mesh_grid_list
You can’t perform that action at this time.
0 commit comments