Skip to content

Commit 330b0a0

Browse files
committed
Terminate create_plots immediately if SMOKE_TEST is set
1 parent c229a3d commit 330b0a0

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

baybe/utils/plotting.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def create_plots(data: pd.DataFrame, path: Path, base_name: str, **kwargs) -> No
1717
The plots will be saved in the location specified by ``path``.
1818
The attribute ``base_name`` is used to define the name of the outputs.
1919
20-
If the ``SMOKE_TEST`` variable is set, no plots are being saved.
20+
If the ``SMOKE_TEST`` variable is set, no plots are being created and this method
21+
immediately returns.
2122
2223
Using the ``BAYBE_MULTIVERSION_PLOTS`` environment variable, it is possible to
2324
create plots for the light and dark version of the documentation. If this variable
@@ -30,7 +31,10 @@ def create_plots(data: pd.DataFrame, path: Path, base_name: str, **kwargs) -> No
3031
**kwargs: Keyword arguments. They are directly passed to ``sns.lineplot`` and
3132
are used for specifying the plot.
3233
"""
33-
# First, we see if we happen to find the plotting themes in the current folder.
34+
# If we run a SMOKE_TEST, we immediately return
35+
if "SMOKE_TEST" in os.environ:
36+
return
37+
# We see if we happen to find the plotting themes in the current folder.
3438
# This is e.g. the case if we convert the file to a jupyter notebook.
3539
try:
3640
themes = json.load(open("plotting_themes.json"))
@@ -64,12 +68,11 @@ def create_plots(data: pd.DataFrame, path: Path, base_name: str, **kwargs) -> No
6468
if kwargs:
6569
sns.lineplot(data=data, **kwargs)
6670
output_path = Path(path, f"{base_name}_{theme_name}.svg")
67-
if "SMOKE_TEST" not in os.environ:
68-
plt.savefig(
69-
output_path,
70-
format="svg",
71-
transparent=True,
72-
)
73-
plt.clf()
71+
plt.savefig(
72+
output_path,
73+
format="svg",
74+
transparent=True,
75+
)
76+
plt.clf()
7477
else:
7578
warnings.warn("No keyword arguments were provided when plotting.")

0 commit comments

Comments
 (0)