|
1 |
| -# Copyright 2020 The PyMC Developers |
| 1 | +# Copyright 2021 The PyMC Developers |
2 | 2 | #
|
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License");
|
4 | 4 | # you may not use this file except in compliance with the License.
|
|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 |
| -"""PyMC3 Plotting. |
| 15 | +"""Alias for the `plots` submodule from ArviZ. |
16 | 16 |
|
17 |
| -Plots are delegated to the `ArviZ <https://arviz-devs.github.io/arviz/>`_ library, a general purpose library for |
18 |
| -exploratory analysis of Bayesian models. For more details, see https://arviz-devs.github.io/arviz/. |
19 |
| -
|
20 |
| -Only `plot_posterior_predictive_glm` is kept in the PyMC code base for now, but it will move to ArviZ once the latter adds features for regression plots. |
| 17 | +Plots are delegated to the ArviZ library, a general purpose library for |
| 18 | +"exploratory analysis of Bayesian models." |
| 19 | +See https://arviz-devs.github.io/arviz/ for details on plots. |
21 | 20 | """
|
22 | 21 | import functools
|
23 | 22 | import sys
|
24 | 23 | import warnings
|
25 | 24 |
|
26 | 25 | import arviz as az
|
27 | 26 |
|
| 27 | +# Makes this module as identical to arviz.plots as possible |
| 28 | +for attr in az.plots.__all__: |
| 29 | + obj = getattr(az.plots, attr) |
| 30 | + if not attr.startswith("__"): |
| 31 | + setattr(sys.modules[__name__], attr, obj) |
| 32 | + |
| 33 | + |
| 34 | +def alias_deprecation(func, alias: str): |
| 35 | + original = func.__name__ |
| 36 | + |
| 37 | + @functools.wraps(func) |
| 38 | + def wrapped(*args, **kwargs): |
| 39 | + raise DeprecationWarning( |
| 40 | + f"The function `{alias}` from PyMC3 was an alias for `{original}` from ArviZ. " |
| 41 | + "It was removed in PyMC3 4.0. " |
| 42 | + f"Switch to `pymc3.{original}` or `arviz.{original}`." |
| 43 | + ) |
| 44 | + |
| 45 | + return wrapped |
| 46 | + |
| 47 | + |
| 48 | +# Aliases of ArviZ functions |
| 49 | +autocorrplot = alias_deprecation(az.plot_autocorr, alias="autocorrplot") |
| 50 | +forestplot = alias_deprecation(az.plot_forest, alias="forestplot") |
| 51 | +kdeplot = alias_deprecation(az.plot_kde, alias="kdeplot") |
| 52 | +energyplot = alias_deprecation(az.plot_energy, alias="energyplot") |
| 53 | +densityplot = alias_deprecation(az.plot_density, alias="densityplot") |
| 54 | +pairplot = alias_deprecation(az.plot_pair, alias="pairplot") |
| 55 | +traceplot = alias_deprecation(az.plot_trace, alias="traceplot") |
| 56 | +compareplot = alias_deprecation(az.plot_compare, alias="compareplot") |
| 57 | + |
| 58 | + |
28 | 59 | from pymc3.plots.posteriorplot import plot_posterior_predictive_glm
|
29 | 60 |
|
30 |
| -__all__ = ["plot_posterior_predictive_glm"] |
| 61 | +__all__ = tuple(az.plots.__all__) + ( |
| 62 | + "autocorrplot", |
| 63 | + "compareplot", |
| 64 | + "forestplot", |
| 65 | + "kdeplot", |
| 66 | + "plot_posterior", |
| 67 | + "traceplot", |
| 68 | + "energyplot", |
| 69 | + "densityplot", |
| 70 | + "pairplot", |
| 71 | + "plot_posterior_predictive_glm", |
| 72 | +) |
0 commit comments