Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change plotting_backend deprecation warning for implicit and explicit matplotlib use #1006

Merged
merged 6 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions neuralprophet/forecaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from neuralprophet.plot_forecast_plotly import plot_components as plot_components_plotly
from neuralprophet.plot_model_parameters_matplotlib import plot_parameters
from neuralprophet.plot_model_parameters_plotly import plot_parameters as plot_parameters_plotly
from neuralprophet.plot_utils import log_warning_deprecation_plotly

log = logging.getLogger("NP.forecaster")

Expand Down Expand Up @@ -1456,10 +1457,7 @@ def set_plotting_backend(self, plotting_backend):
"""
if plotting_backend in ["plotly", "matplotlib"]:
self.plotting_backend = plotting_backend
if self.plotting_backend == "matplotlib":
log.warning(
"DeprecationWarning: default plotting_backend will be changed to plotly in a future version. Switch to plotly by calling `m.set_plotting_backend('plotly')`."
)
log_warning_deprecation_plotly(self.plotting_backend)
else:
raise ValueError("The parameter `plotting_backend` must be either 'plotly' or 'matplotlib'.")

Expand Down Expand Up @@ -1573,6 +1571,8 @@ def plot(
if plotting_backend != "default"
else (self.plotting_backend if hasattr(self, "plotting_backend") else "matplotlib")
)
log_warning_deprecation_plotly(plotting_backend)

if plotting_backend == "plotly":
return plot_plotly(
fcst=fcst,
Expand Down Expand Up @@ -1735,6 +1735,7 @@ def plot_latest_forecast(
if plotting_backend != "default"
else (self.plotting_backend if hasattr(self, "plotting_backend") else "matplotlib")
)
log_warning_deprecation_plotly(plotting_backend)
if plotting_backend == "plotly":
return plot_plotly(
fcst=fcst,
Expand Down Expand Up @@ -1774,6 +1775,7 @@ def plot_last_forecast(
"plot_last_forecast() has been renamed to plot_latest_forecast() and is therefore deprecated. "
"Please use plot_latst_forecast() in the future"
)

return NeuralProphet.plot_latest_forecast(**args)

def plot_components(
Expand Down Expand Up @@ -1894,6 +1896,7 @@ def plot_components(
if plotting_backend != "default"
else (self.plotting_backend if hasattr(self, "plotting_backend") else "matplotlib")
)
log_warning_deprecation_plotly(plotting_backend)

if plotting_backend == "plotly":
return plot_components_plotly(
Expand Down Expand Up @@ -2043,6 +2046,7 @@ def plot_parameters(
if plotting_backend != "default"
else (self.plotting_backend if hasattr(self, "plotting_backend") else "matplotlib")
)
log_warning_deprecation_plotly(plotting_backend)
if plotting_backend == "plotly":
return plot_parameters_plotly(
m=self,
Expand Down
11 changes: 11 additions & 0 deletions neuralprophet/plot_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import logging

log = logging.getLogger("NP.plotting")


def log_warning_deprecation_plotly(plotting_backend):
noxan marked this conversation as resolved.
Show resolved Hide resolved
if plotting_backend == "matplotlib":
log.warning(
"DeprecationWarning: default plotting_backend will be changed to plotly in a future version. "
"Switch to plotly by calling `m.set_plotting_backend('plotly')`."
)