Skip to content

Commit 434bac4

Browse files
authored
Merge pull request #255 from PyAutoLabs/feature/fast-plots-skip-savefig
perf: skip savefig rendering in PYAUTO_FAST_PLOTS mode
2 parents 408ceee + d5f17b7 commit 434bac4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

autoarray/plot/utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
logger = logging.getLogger(__name__)
1313

1414

15+
_FAST_PLOTS = os.environ.get("PYAUTO_FAST_PLOTS") == "1"
16+
17+
1518
def tight_layout():
1619
"""Call ``plt.tight_layout()`` unless fast-plot mode is active.
1720
1821
When ``PYAUTO_FAST_PLOTS=1`` the expensive layout-optimisation pass
1922
is skipped. All figure creation, data computation, and rendering
2023
still execute — only the final spacing adjustment is bypassed.
2124
"""
22-
if os.environ.get("PYAUTO_FAST_PLOTS") == "1":
25+
if _FAST_PLOTS:
2326
return
2427
plt.tight_layout()
2528

@@ -338,6 +341,10 @@ def subplot_save(fig, output_path, output_filename, output_format=None):
338341
if _output_mode_save(fig, output_filename):
339342
return
340343

344+
if _FAST_PLOTS:
345+
plt.close(fig)
346+
return
347+
341348
if output_format == "show" or not output_path:
342349
plt.show()
343350
else:
@@ -508,6 +515,10 @@ def save_figure(
508515
if _output_mode_save(fig, filename):
509516
return
510517

518+
if _FAST_PLOTS:
519+
plt.close(fig)
520+
return
521+
511522
formats = format if isinstance(format, (list, tuple)) else [format]
512523

513524
if all(f == "show" for f in formats) or not path:

0 commit comments

Comments
 (0)