From 2827dd8878f03071087e5e86f85d8f01a6dbf04e Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 7 Apr 2026 17:06:32 +0100 Subject: [PATCH] perf: cache galaxy_model_image_dict and model_images_of_planes_list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change from @property to @cached_property to avoid recomputing the full ray-tracing chain 4 times per subplot_fit_imaging call. The subplot accesses these via _get_source_vmax, per-plane panels, and subtracted_images_of_planes_list — now all share the single cached result. Co-Authored-By: Claude Opus 4.6 (1M context) --- autolens/imaging/fit_imaging.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autolens/imaging/fit_imaging.py b/autolens/imaging/fit_imaging.py index 805ce3499..796369a81 100644 --- a/autolens/imaging/fit_imaging.py +++ b/autolens/imaging/fit_imaging.py @@ -198,7 +198,7 @@ def galaxy_image_dict(self) -> Dict[ag.Galaxy, np.ndarray]: return {**galaxy_image_2d_dict, **galaxy_linear_obj_image_dict} - @property + @cached_property def galaxy_model_image_dict(self) -> Dict[ag.Galaxy, np.ndarray]: """ A dictionary which associates every galaxy in the tracer with its `model_image`. @@ -268,7 +268,7 @@ def subtracted_signal_to_noise_maps_of_galaxies_dict(self) -> Dict[ag.Galaxy, np return subtracted_signal_to_noise_maps_of_galaxies_dict - @property + @cached_property def model_images_of_planes_list(self) -> List[aa.Array2D]: """ A list of every model image of every plane in the tracer.