Skip to content

Commit

Permalink
set matplotlib backend (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
pplonski committed Jan 10, 2025
1 parent da2aa81 commit 1508365
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions supervised/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import matplotlib

matplotlib.use("Agg")
import warnings

warnings.filterwarnings("ignore", message=".*The 'nopython' keyword.*")
Expand Down Expand Up @@ -429,7 +428,14 @@ def fit(
Returns:
AutoML object: Returns `self`
"""
return self._fit(X, y, sample_weight, cv, sensitive_features)
try:
original_backend = matplotlib.get_backend()
matplotlib.use("Agg")
return self._fit(X, y, sample_weight, cv, sensitive_features)
except Exception as e:
raise e
finally:
matplotlib.use(original_backend)

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

0 comments on commit 1508365

Please sign in to comment.