From 282970ebad1c344e39d12aebdb5096bcfb7c8692 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 7 Apr 2026 08:42:22 +0100 Subject: [PATCH] feat: use tight_layout wrapper for PYAUTO_FAST_PLOTS support Replace all plt.tight_layout() calls with the wrapper from autoarray.plot.utils that skips the expensive layout pass when PYAUTO_FAST_PLOTS=1 is set. Co-Authored-By: Claude Opus 4.6 (1M context) --- autogalaxy/ellipse/plot/fit_ellipse_plots.py | 6 +++--- autogalaxy/galaxy/plot/adapt_plots.py | 4 ++-- autogalaxy/galaxy/plot/galaxies_plots.py | 6 +++--- autogalaxy/galaxy/plot/galaxy_plots.py | 6 +++--- autogalaxy/imaging/plot/fit_imaging_plots.py | 8 ++++---- .../interferometer/plot/fit_interferometer_plots.py | 8 ++++---- autogalaxy/profiles/plot/basis_plots.py | 4 ++-- autogalaxy/quantity/plot/fit_quantity_plots.py | 4 ++-- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/autogalaxy/ellipse/plot/fit_ellipse_plots.py b/autogalaxy/ellipse/plot/fit_ellipse_plots.py index e2cc626f..cbbd40c4 100644 --- a/autogalaxy/ellipse/plot/fit_ellipse_plots.py +++ b/autogalaxy/ellipse/plot/fit_ellipse_plots.py @@ -5,7 +5,7 @@ import autoarray as aa from autoarray import plot as aplt -from autoarray.plot.utils import conf_subplot_figsize +from autoarray.plot.utils import conf_subplot_figsize, tight_layout from autogalaxy.ellipse.plot import fit_ellipse_plot_util from autogalaxy.ellipse.fit_ellipse import FitEllipse @@ -159,7 +159,7 @@ def subplot_fit_ellipse( ) _plot_ellipse_residuals(fit_list=fit_list, for_subplot=True, ax=axes[1]) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "fit_ellipse", output_format) @@ -242,5 +242,5 @@ def subplot_ellipse_errors( ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "ellipse_errors", output_format) diff --git a/autogalaxy/galaxy/plot/adapt_plots.py b/autogalaxy/galaxy/plot/adapt_plots.py index a00e8dba..c3143425 100644 --- a/autogalaxy/galaxy/plot/adapt_plots.py +++ b/autogalaxy/galaxy/plot/adapt_plots.py @@ -3,7 +3,7 @@ from typing import Dict import autoarray as aa -from autoarray.plot.utils import conf_subplot_figsize +from autoarray.plot.utils import conf_subplot_figsize, tight_layout from autogalaxy.galaxy.galaxy import Galaxy from autogalaxy.plot.plot_utils import plot_array, _save_subplot @@ -58,7 +58,7 @@ def subplot_adapt_images( ax=axes_list[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "adapt_images", output_format) diff --git a/autogalaxy/galaxy/plot/galaxies_plots.py b/autogalaxy/galaxy/plot/galaxies_plots.py index bc83529c..67f16add 100644 --- a/autogalaxy/galaxy/plot/galaxies_plots.py +++ b/autogalaxy/galaxy/plot/galaxies_plots.py @@ -5,7 +5,7 @@ from autogalaxy.galaxy.galaxies import Galaxies from autogalaxy.plot.plot_utils import _to_lines, _to_positions, plot_array, plot_grid, _save_subplot, _critical_curves_from -from autoarray.plot.utils import hide_unused_axes, conf_subplot_figsize +from autoarray.plot.utils import hide_unused_axes, conf_subplot_figsize, tight_layout from autogalaxy import exc @@ -156,7 +156,7 @@ def _defl_x(): ) hide_unused_axes(axes_flat) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, auto_filename, output_format) @@ -213,7 +213,7 @@ def subplot_galaxy_images( ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "galaxy_images", output_format) diff --git a/autogalaxy/galaxy/plot/galaxy_plots.py b/autogalaxy/galaxy/plot/galaxy_plots.py index f97a9b94..3505ffff 100644 --- a/autogalaxy/galaxy/plot/galaxy_plots.py +++ b/autogalaxy/galaxy/plot/galaxy_plots.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING import autoarray as aa -from autoarray.plot.utils import conf_subplot_figsize +from autoarray.plot.utils import conf_subplot_figsize, tight_layout from autogalaxy.galaxy.galaxy import Galaxy from autogalaxy.profiles.light.abstract import LightProfile @@ -60,7 +60,7 @@ def subplot_of_light_profiles( ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "image", output_format) @@ -142,5 +142,5 @@ def _deflections_x(mp): ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, name, output_format) diff --git a/autogalaxy/imaging/plot/fit_imaging_plots.py b/autogalaxy/imaging/plot/fit_imaging_plots.py index 57516fef..58bf0660 100644 --- a/autogalaxy/imaging/plot/fit_imaging_plots.py +++ b/autogalaxy/imaging/plot/fit_imaging_plots.py @@ -3,7 +3,7 @@ import autoarray as aa from autoconf.fitsable import hdu_list_for_output_from -from autoarray.plot.utils import conf_subplot_figsize +from autoarray.plot.utils import conf_subplot_figsize, tight_layout from autogalaxy.imaging.fit_imaging import FitImaging from autogalaxy.plot.plot_utils import plot_array, _save_subplot @@ -64,7 +64,7 @@ def subplot_fit( ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "fit", output_format) @@ -128,7 +128,7 @@ def subplot_of_galaxy( ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, f"of_galaxy_{galaxy_index}", output_format) @@ -165,7 +165,7 @@ def subplot_fit_imaging_list( plot_array(array=fit.model_data, title="Model Image", ax=axes[i][2]) plot_array(array=fit.normalized_residual_map, title="Normalized Residual Map", cb_unit=r"$\sigma$", ax=axes[i][3]) plot_array(array=fit.chi_squared_map, title="Chi-Squared Map", cb_unit=r"$\chi^2$", ax=axes[i][4]) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, output_filename, output_format) diff --git a/autogalaxy/interferometer/plot/fit_interferometer_plots.py b/autogalaxy/interferometer/plot/fit_interferometer_plots.py index c7ffa4c9..1e30fd35 100644 --- a/autogalaxy/interferometer/plot/fit_interferometer_plots.py +++ b/autogalaxy/interferometer/plot/fit_interferometer_plots.py @@ -5,7 +5,7 @@ import autoarray as aa from autoconf.fitsable import hdu_list_for_output_from from autoarray.plot import plot_visibilities_1d -from autoarray.plot.utils import conf_subplot_figsize +from autoarray.plot.utils import conf_subplot_figsize, tight_layout from autogalaxy.interferometer.fit_interferometer import FitInterferometer from autogalaxy.galaxy.plot import galaxies_plots @@ -54,7 +54,7 @@ def subplot_fit( for i, (vis, title) in enumerate(panels): plot_visibilities_1d(vis, axes_flat[i], title) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "fit", output_format) @@ -110,7 +110,7 @@ def subplot_fit_dirty_images( ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "fit_dirty_images", output_format) @@ -175,7 +175,7 @@ def subplot_fit_real_space( use_log10=use_log10, ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "fit_real_space", output_format) diff --git a/autogalaxy/profiles/plot/basis_plots.py b/autogalaxy/profiles/plot/basis_plots.py index d125dddf..3fb1c13e 100644 --- a/autogalaxy/profiles/plot/basis_plots.py +++ b/autogalaxy/profiles/plot/basis_plots.py @@ -2,7 +2,7 @@ import numpy as np import autoarray as aa -from autoarray.plot.utils import conf_subplot_figsize +from autoarray.plot.utils import conf_subplot_figsize, tight_layout from autogalaxy.profiles.basis import Basis from autogalaxy.plot.plot_utils import _to_positions, plot_array, _save_subplot @@ -76,5 +76,5 @@ def subplot_image( ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, "basis_image", output_format) diff --git a/autogalaxy/quantity/plot/fit_quantity_plots.py b/autogalaxy/quantity/plot/fit_quantity_plots.py index a26e66d7..12e7396b 100644 --- a/autogalaxy/quantity/plot/fit_quantity_plots.py +++ b/autogalaxy/quantity/plot/fit_quantity_plots.py @@ -1,7 +1,7 @@ import matplotlib.pyplot as plt import autoarray as aa -from autoarray.plot.utils import conf_subplot_figsize +from autoarray.plot.utils import conf_subplot_figsize, tight_layout from autogalaxy.quantity.fit_quantity import FitQuantity from autogalaxy.plot.plot_utils import plot_array, _save_subplot @@ -56,7 +56,7 @@ def _subplot_fit_array(fit, output_path, output_format, colormap, use_log10, pos ax=axes_flat[i], ) - plt.tight_layout() + tight_layout() _save_subplot(fig, output_path, filename, output_format)