Skip to content

Commit 57a1291

Browse files
authored
Merge pull request #361 from PyAutoLabs/feature/fit-imaging-pytree-delaunay
feat: Delaunay-pixelization JIT round-trip support in galaxy→inversion path
2 parents 73bcd8e + c442209 commit 57a1291

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

autogalaxy/galaxy/to_inversion.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)