Skip to content

Commit 18f507d

Browse files
committed
Fix lazy import of optional packages
1 parent 8bceb86 commit 18f507d

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

baybe/utils/plotting.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""Plotting utilities."""
22

3+
import json
34
import os
5+
import sys
6+
import warnings
47
from pathlib import Path
58

69
import pandas as pd
@@ -32,10 +35,7 @@ def create_example_plots(
3235
if "SMOKE_TEST" in os.environ:
3336
return
3437

35-
# Lazily import required packages
36-
import json
37-
import sys
38-
38+
# Lazily import optional packages which are now required
3939
import matplotlib.pyplot as plt
4040
import seaborn as sns
4141

@@ -52,8 +52,6 @@ def create_example_plots(
5252
while not script_path.name == "baybe" and script_path != script_path.parent:
5353
script_path = script_path.parent
5454
if script_path == script_path.parent:
55-
import warnings
56-
5755
warnings.warn("No themes for plotting found. A default theme is used.")
5856
themes = {"check": {"font_scale": 1.75, "rc_params": {}}}
5957
else:
@@ -77,6 +75,4 @@ def create_example_plots(
7775
)
7876
plt.clf()
7977
else:
80-
import warnings
81-
8278
warnings.warn("No keyword arguments were provided when plotting.")

0 commit comments

Comments
 (0)