4
4
"exploratory analysis of Bayesian models." See https://arviz-devs.github.io/arviz/
5
5
for details on plots.
6
6
"""
7
+ import functools
8
+ import sys
9
+ import warnings
7
10
try :
8
11
import arviz as az
9
12
except ImportError : # arviz is optional, throw exception when used
10
13
11
14
class _ImportWarner :
15
+ __all__ = []
16
+
12
17
def __init__ (self , attr ):
13
18
self .attr = attr
14
19
@@ -21,17 +26,47 @@ class _ArviZ:
21
26
def __getattr__ (self , attr ):
22
27
return _ImportWarner (attr )
23
28
29
+
24
30
az = _ArviZ ()
25
31
32
+ def map_args (func ):
33
+ swaps = [
34
+ ('varnames' , 'var_names' )
35
+ ]
36
+ @functools .wraps (func )
37
+ def wrapped (* args , ** kwargs ):
38
+ for (old , new ) in swaps :
39
+ if old in kwargs and new not in kwargs :
40
+ warnings .warn ('Keyword argument `{old}` renamed to `{new}`, and will be removed in pymc3 3.8' .format (old = old , new = new ))
41
+ kwargs [new ] = kwargs .pop (old )
42
+ return func (* args , ** kwargs )
43
+ return wrapped
26
44
27
- autocorrplot = az .plot_autocorr
28
- compareplot = az .plot_compare
29
- forestplot = az .plot_forest
30
- kdeplot = az .plot_kde
31
- plot_posterior = az .plot_posterior
32
- traceplot = az .plot_trace
33
- energyplot = az .plot_energy
34
- densityplot = az .plot_density
35
- pairplot = az .plot_pair
45
+ autocorrplot = map_args ( az .plot_autocorr )
46
+ compareplot = map_args ( az .plot_compare )
47
+ forestplot = map_args ( az .plot_forest )
48
+ kdeplot = map_args ( az .plot_kde )
49
+ plot_posterior = map_args ( az .plot_posterior )
50
+ traceplot = map_args ( az .plot_trace )
51
+ energyplot = map_args ( az .plot_energy )
52
+ densityplot = map_args ( az .plot_density )
53
+ pairplot = map_args ( az .plot_pair )
36
54
37
55
from .posteriorplot import plot_posterior_predictive_glm
56
+
57
+
58
+ for plot in az .plots .__all__ :
59
+ setattr (sys .modules [__name__ ], plot , map_args (getattr (az .plots , plot )))
60
+
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