Skip to content

Commit 1508365

Browse files
committed
set matplotlib backend (#785)
1 parent da2aa81 commit 1508365

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

supervised/automl.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import matplotlib
44

5-
matplotlib.use("Agg")
65
import warnings
76

87
warnings.filterwarnings("ignore", message=".*The 'nopython' keyword.*")
@@ -429,7 +428,14 @@ def fit(
429428
Returns:
430429
AutoML object: Returns `self`
431430
"""
432-
return self._fit(X, y, sample_weight, cv, sensitive_features)
431+
try:
432+
original_backend = matplotlib.get_backend()
433+
matplotlib.use("Agg")
434+
return self._fit(X, y, sample_weight, cv, sensitive_features)
435+
except Exception as e:
436+
raise e
437+
finally:
438+
matplotlib.use(original_backend)
433439

434440
def predict(self, X: Union[List, numpy.ndarray, pandas.DataFrame]) -> numpy.ndarray:
435441
"""

0 commit comments

Comments
 (0)