Skip to content

Commit 282970e

Browse files
Jammy2211claude
authored andcommitted
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) <noreply@anthropic.com>
1 parent 6dd5f42 commit 282970e

8 files changed

Lines changed: 23 additions & 23 deletions

File tree

autogalaxy/ellipse/plot/fit_ellipse_plots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import autoarray as aa
77
from autoarray import plot as aplt
8-
from autoarray.plot.utils import conf_subplot_figsize
8+
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
99

1010
from autogalaxy.ellipse.plot import fit_ellipse_plot_util
1111
from autogalaxy.ellipse.fit_ellipse import FitEllipse
@@ -159,7 +159,7 @@ def subplot_fit_ellipse(
159159
)
160160
_plot_ellipse_residuals(fit_list=fit_list, for_subplot=True, ax=axes[1])
161161

162-
plt.tight_layout()
162+
tight_layout()
163163
_save_subplot(fig, output_path, "fit_ellipse", output_format)
164164

165165

@@ -242,5 +242,5 @@ def subplot_ellipse_errors(
242242
ax=axes_flat[i],
243243
)
244244

245-
plt.tight_layout()
245+
tight_layout()
246246
_save_subplot(fig, output_path, "ellipse_errors", output_format)

autogalaxy/galaxy/plot/adapt_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Dict
44

55
import autoarray as aa
6-
from autoarray.plot.utils import conf_subplot_figsize
6+
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
77

88
from autogalaxy.galaxy.galaxy import Galaxy
99
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
@@ -58,7 +58,7 @@ def subplot_adapt_images(
5858
ax=axes_list[i],
5959
)
6060

61-
plt.tight_layout()
61+
tight_layout()
6262
_save_subplot(fig, output_path, "adapt_images", output_format)
6363

6464

autogalaxy/galaxy/plot/galaxies_plots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from autogalaxy.galaxy.galaxies import Galaxies
77
from autogalaxy.plot.plot_utils import _to_lines, _to_positions, plot_array, plot_grid, _save_subplot, _critical_curves_from
8-
from autoarray.plot.utils import hide_unused_axes, conf_subplot_figsize
8+
from autoarray.plot.utils import hide_unused_axes, conf_subplot_figsize, tight_layout
99
from autogalaxy import exc
1010

1111

@@ -156,7 +156,7 @@ def _defl_x():
156156
)
157157

158158
hide_unused_axes(axes_flat)
159-
plt.tight_layout()
159+
tight_layout()
160160
_save_subplot(fig, output_path, auto_filename, output_format)
161161

162162

@@ -213,7 +213,7 @@ def subplot_galaxy_images(
213213
ax=axes_flat[i],
214214
)
215215

216-
plt.tight_layout()
216+
tight_layout()
217217
_save_subplot(fig, output_path, "galaxy_images", output_format)
218218

219219

autogalaxy/galaxy/plot/galaxy_plots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import TYPE_CHECKING
44

55
import autoarray as aa
6-
from autoarray.plot.utils import conf_subplot_figsize
6+
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
77

88
from autogalaxy.galaxy.galaxy import Galaxy
99
from autogalaxy.profiles.light.abstract import LightProfile
@@ -60,7 +60,7 @@ def subplot_of_light_profiles(
6060
ax=axes_flat[i],
6161
)
6262

63-
plt.tight_layout()
63+
tight_layout()
6464
_save_subplot(fig, output_path, "image", output_format)
6565

6666

@@ -142,5 +142,5 @@ def _deflections_x(mp):
142142
ax=axes_flat[i],
143143
)
144144

145-
plt.tight_layout()
145+
tight_layout()
146146
_save_subplot(fig, output_path, name, output_format)

autogalaxy/imaging/plot/fit_imaging_plots.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import autoarray as aa
55
from autoconf.fitsable import hdu_list_for_output_from
6-
from autoarray.plot.utils import conf_subplot_figsize
6+
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
77

88
from autogalaxy.imaging.fit_imaging import FitImaging
99
from autogalaxy.plot.plot_utils import plot_array, _save_subplot
@@ -64,7 +64,7 @@ def subplot_fit(
6464
ax=axes_flat[i],
6565
)
6666

67-
plt.tight_layout()
67+
tight_layout()
6868
_save_subplot(fig, output_path, "fit", output_format)
6969

7070

@@ -128,7 +128,7 @@ def subplot_of_galaxy(
128128
ax=axes_flat[i],
129129
)
130130

131-
plt.tight_layout()
131+
tight_layout()
132132
_save_subplot(fig, output_path, f"of_galaxy_{galaxy_index}", output_format)
133133

134134

@@ -165,7 +165,7 @@ def subplot_fit_imaging_list(
165165
plot_array(array=fit.model_data, title="Model Image", ax=axes[i][2])
166166
plot_array(array=fit.normalized_residual_map, title="Normalized Residual Map", cb_unit=r"$\sigma$", ax=axes[i][3])
167167
plot_array(array=fit.chi_squared_map, title="Chi-Squared Map", cb_unit=r"$\chi^2$", ax=axes[i][4])
168-
plt.tight_layout()
168+
tight_layout()
169169
_save_subplot(fig, output_path, output_filename, output_format)
170170

171171

autogalaxy/interferometer/plot/fit_interferometer_plots.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import autoarray as aa
66
from autoconf.fitsable import hdu_list_for_output_from
77
from autoarray.plot import plot_visibilities_1d
8-
from autoarray.plot.utils import conf_subplot_figsize
8+
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
99

1010
from autogalaxy.interferometer.fit_interferometer import FitInterferometer
1111
from autogalaxy.galaxy.plot import galaxies_plots
@@ -54,7 +54,7 @@ def subplot_fit(
5454
for i, (vis, title) in enumerate(panels):
5555
plot_visibilities_1d(vis, axes_flat[i], title)
5656

57-
plt.tight_layout()
57+
tight_layout()
5858
_save_subplot(fig, output_path, "fit", output_format)
5959

6060

@@ -110,7 +110,7 @@ def subplot_fit_dirty_images(
110110
ax=axes_flat[i],
111111
)
112112

113-
plt.tight_layout()
113+
tight_layout()
114114
_save_subplot(fig, output_path, "fit_dirty_images", output_format)
115115

116116

@@ -175,7 +175,7 @@ def subplot_fit_real_space(
175175
use_log10=use_log10,
176176
ax=axes_flat[i],
177177
)
178-
plt.tight_layout()
178+
tight_layout()
179179
_save_subplot(fig, output_path, "fit_real_space", output_format)
180180

181181

autogalaxy/profiles/plot/basis_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33

44
import autoarray as aa
5-
from autoarray.plot.utils import conf_subplot_figsize
5+
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
66

77
from autogalaxy.profiles.basis import Basis
88
from autogalaxy.plot.plot_utils import _to_positions, plot_array, _save_subplot
@@ -76,5 +76,5 @@ def subplot_image(
7676
ax=axes_flat[i],
7777
)
7878

79-
plt.tight_layout()
79+
tight_layout()
8080
_save_subplot(fig, output_path, "basis_image", output_format)

autogalaxy/quantity/plot/fit_quantity_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import matplotlib.pyplot as plt
22

33
import autoarray as aa
4-
from autoarray.plot.utils import conf_subplot_figsize
4+
from autoarray.plot.utils import conf_subplot_figsize, tight_layout
55

66
from autogalaxy.quantity.fit_quantity import FitQuantity
77
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
5656
ax=axes_flat[i],
5757
)
5858

59-
plt.tight_layout()
59+
tight_layout()
6060
_save_subplot(fig, output_path, filename, output_format)
6161

6262

0 commit comments

Comments
 (0)