diff --git a/pymc/__init__.py b/pymc/__init__.py index 36763ec34b..ceceeb2ce6 100644 --- a/pymc/__init__.py +++ b/pymc/__init__.py @@ -54,6 +54,7 @@ def __set_compiler_flags(): from pymc.model.core import * from pymc.model.transform.conditioning import do, observe from pymc.model_graph import model_to_graphviz, model_to_networkx +from pymc.plots import DEPRECATED_PLOTS_ALIASES from pymc.pytensorf import * from pymc.sampling import * from pymc.smc import * @@ -62,3 +63,14 @@ def __set_compiler_flags(): from pymc.variational import * __version__ = _version.get_versions()["version"] + + +def __getattr__(name): + if name in DEPRECATED_PLOTS_ALIASES: + new_name = DEPRECATED_PLOTS_ALIASES[name] + raise ImportError( + f"The function `{name}` from PyMC was an alias for `{new_name}` from " + f"ArviZ. It was removed in PyMC 4.0. " + f"Switch to `pymc.{new_name}` or `arviz.{new_name}`." + ) + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/pymc/plots/__init__.py b/pymc/plots/__init__.py index ef7816b22f..3828b81797 100644 --- a/pymc/plots/__init__.py +++ b/pymc/plots/__init__.py @@ -28,3 +28,25 @@ obj = getattr(az.plots, attr) if not attr.startswith("__"): setattr(sys.modules[__name__], attr, obj) + +DEPRECATED_PLOTS_ALIASES = dict( + autocorrplot="plot_autocorr", + forestplot="plot_forest", + kdeplot="plot_kde", + energyplot="plot_energy", + densityplot="plot_density", + pairplot="plot_pair", + traceplot="plot_trace", + compareplot="plot_compare", +) + + +def __getattr__(name): + if name in DEPRECATED_PLOTS_ALIASES: + new_name = DEPRECATED_PLOTS_ALIASES[name] + raise ImportError( + f"The function `{name}` from PyMC was an alias for `{new_name}` from " + f"ArviZ. It was removed in PyMC 4.0. " + f"Switch to `pymc.{new_name}` or `arviz.{new_name}`." + ) + raise AttributeError(f"module {__name__!r} has no attribute {name!r}")