From 08d85abe12e363dbb9fa1816a6ca4c6a7af99f0a Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sun, 24 May 2026 16:57:03 +0100 Subject: [PATCH] feat: SimulatorInterferometer.via_galaxies_from auto-defaults xp from parent Changes via_galaxies_from on autogalaxy's SimulatorInterferometer override to accept xp=None and fall back to self._xp inherited from aa.SimulatorInterferometer. When the simulator is constructed with use_jax=True, via_galaxies_from now routes xp=jnp through galaxies.image_2d_from and via_image_from without the user passing xp explicitly. Depends on Jammy2211/PyAutoArray PR adding use_jax constructor flag + _xp property to the parent aa.SimulatorInterferometer. Part of Phase 2 PR 3 of z_features/jax_user_intro.md. Issue: PyAutoArray#334 Co-Authored-By: Claude Opus 4.7 (1M context) --- autogalaxy/interferometer/simulator.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/autogalaxy/interferometer/simulator.py b/autogalaxy/interferometer/simulator.py index 9d618963..65118b2f 100644 --- a/autogalaxy/interferometer/simulator.py +++ b/autogalaxy/interferometer/simulator.py @@ -16,7 +16,7 @@ class SimulatorInterferometer(aa.SimulatorInterferometer): - def via_galaxies_from(self, galaxies: List[Galaxy], grid: aa.type.Grid2DLike): + def via_galaxies_from(self, galaxies: List[Galaxy], grid: aa.type.Grid2DLike, xp=None): """ Returns a realistic simulated image by applying effects to a plain simulated image. @@ -37,8 +37,11 @@ def via_galaxies_from(self, galaxies: List[Galaxy], grid: aa.type.Grid2DLike): A seed for random noise_maps generation """ + if xp is None: + xp = self._xp + galaxies = Galaxies(galaxies=galaxies) - image = galaxies.image_2d_from(grid=grid) + image = galaxies.image_2d_from(grid=grid, xp=xp) - return self.via_image_from(image=image) + return self.via_image_from(image=image, xp=xp)