arviz 0.23.3__py3-none-any.whl → 1.0.0rc0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arviz/__init__.py +52 -367
- arviz-1.0.0rc0.dist-info/METADATA +182 -0
- arviz-1.0.0rc0.dist-info/RECORD +5 -0
- {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/WHEEL +1 -2
- {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/licenses/LICENSE +0 -1
- arviz/data/__init__.py +0 -55
- arviz/data/base.py +0 -596
- arviz/data/converters.py +0 -203
- arviz/data/datasets.py +0 -161
- arviz/data/example_data/code/radon/radon.json +0 -326
- arviz/data/example_data/data/centered_eight.nc +0 -0
- arviz/data/example_data/data/non_centered_eight.nc +0 -0
- arviz/data/example_data/data_local.json +0 -12
- arviz/data/example_data/data_remote.json +0 -58
- arviz/data/inference_data.py +0 -2386
- arviz/data/io_beanmachine.py +0 -112
- arviz/data/io_cmdstan.py +0 -1036
- arviz/data/io_cmdstanpy.py +0 -1233
- arviz/data/io_datatree.py +0 -23
- arviz/data/io_dict.py +0 -462
- arviz/data/io_emcee.py +0 -317
- arviz/data/io_json.py +0 -54
- arviz/data/io_netcdf.py +0 -68
- arviz/data/io_numpyro.py +0 -497
- arviz/data/io_pyjags.py +0 -378
- arviz/data/io_pyro.py +0 -333
- arviz/data/io_pystan.py +0 -1095
- arviz/data/io_zarr.py +0 -46
- arviz/data/utils.py +0 -139
- arviz/labels.py +0 -210
- arviz/plots/__init__.py +0 -61
- arviz/plots/autocorrplot.py +0 -171
- arviz/plots/backends/__init__.py +0 -223
- arviz/plots/backends/bokeh/__init__.py +0 -166
- arviz/plots/backends/bokeh/autocorrplot.py +0 -101
- arviz/plots/backends/bokeh/bfplot.py +0 -23
- arviz/plots/backends/bokeh/bpvplot.py +0 -193
- arviz/plots/backends/bokeh/compareplot.py +0 -167
- arviz/plots/backends/bokeh/densityplot.py +0 -239
- arviz/plots/backends/bokeh/distcomparisonplot.py +0 -23
- arviz/plots/backends/bokeh/distplot.py +0 -183
- arviz/plots/backends/bokeh/dotplot.py +0 -113
- arviz/plots/backends/bokeh/ecdfplot.py +0 -73
- arviz/plots/backends/bokeh/elpdplot.py +0 -203
- arviz/plots/backends/bokeh/energyplot.py +0 -155
- arviz/plots/backends/bokeh/essplot.py +0 -176
- arviz/plots/backends/bokeh/forestplot.py +0 -772
- arviz/plots/backends/bokeh/hdiplot.py +0 -54
- arviz/plots/backends/bokeh/kdeplot.py +0 -268
- arviz/plots/backends/bokeh/khatplot.py +0 -163
- arviz/plots/backends/bokeh/lmplot.py +0 -185
- arviz/plots/backends/bokeh/loopitplot.py +0 -211
- arviz/plots/backends/bokeh/mcseplot.py +0 -184
- arviz/plots/backends/bokeh/pairplot.py +0 -328
- arviz/plots/backends/bokeh/parallelplot.py +0 -81
- arviz/plots/backends/bokeh/posteriorplot.py +0 -324
- arviz/plots/backends/bokeh/ppcplot.py +0 -379
- arviz/plots/backends/bokeh/rankplot.py +0 -149
- arviz/plots/backends/bokeh/separationplot.py +0 -107
- arviz/plots/backends/bokeh/traceplot.py +0 -436
- arviz/plots/backends/bokeh/violinplot.py +0 -164
- arviz/plots/backends/matplotlib/__init__.py +0 -124
- arviz/plots/backends/matplotlib/autocorrplot.py +0 -72
- arviz/plots/backends/matplotlib/bfplot.py +0 -78
- arviz/plots/backends/matplotlib/bpvplot.py +0 -177
- arviz/plots/backends/matplotlib/compareplot.py +0 -135
- arviz/plots/backends/matplotlib/densityplot.py +0 -194
- arviz/plots/backends/matplotlib/distcomparisonplot.py +0 -119
- arviz/plots/backends/matplotlib/distplot.py +0 -178
- arviz/plots/backends/matplotlib/dotplot.py +0 -116
- arviz/plots/backends/matplotlib/ecdfplot.py +0 -70
- arviz/plots/backends/matplotlib/elpdplot.py +0 -189
- arviz/plots/backends/matplotlib/energyplot.py +0 -113
- arviz/plots/backends/matplotlib/essplot.py +0 -180
- arviz/plots/backends/matplotlib/forestplot.py +0 -656
- arviz/plots/backends/matplotlib/hdiplot.py +0 -48
- arviz/plots/backends/matplotlib/kdeplot.py +0 -177
- arviz/plots/backends/matplotlib/khatplot.py +0 -241
- arviz/plots/backends/matplotlib/lmplot.py +0 -149
- arviz/plots/backends/matplotlib/loopitplot.py +0 -144
- arviz/plots/backends/matplotlib/mcseplot.py +0 -161
- arviz/plots/backends/matplotlib/pairplot.py +0 -355
- arviz/plots/backends/matplotlib/parallelplot.py +0 -58
- arviz/plots/backends/matplotlib/posteriorplot.py +0 -348
- arviz/plots/backends/matplotlib/ppcplot.py +0 -478
- arviz/plots/backends/matplotlib/rankplot.py +0 -119
- arviz/plots/backends/matplotlib/separationplot.py +0 -97
- arviz/plots/backends/matplotlib/traceplot.py +0 -526
- arviz/plots/backends/matplotlib/tsplot.py +0 -121
- arviz/plots/backends/matplotlib/violinplot.py +0 -148
- arviz/plots/bfplot.py +0 -128
- arviz/plots/bpvplot.py +0 -308
- arviz/plots/compareplot.py +0 -177
- arviz/plots/densityplot.py +0 -284
- arviz/plots/distcomparisonplot.py +0 -197
- arviz/plots/distplot.py +0 -233
- arviz/plots/dotplot.py +0 -233
- arviz/plots/ecdfplot.py +0 -372
- arviz/plots/elpdplot.py +0 -174
- arviz/plots/energyplot.py +0 -147
- arviz/plots/essplot.py +0 -319
- arviz/plots/forestplot.py +0 -304
- arviz/plots/hdiplot.py +0 -211
- arviz/plots/kdeplot.py +0 -357
- arviz/plots/khatplot.py +0 -236
- arviz/plots/lmplot.py +0 -380
- arviz/plots/loopitplot.py +0 -224
- arviz/plots/mcseplot.py +0 -194
- arviz/plots/pairplot.py +0 -281
- arviz/plots/parallelplot.py +0 -204
- arviz/plots/plot_utils.py +0 -599
- arviz/plots/posteriorplot.py +0 -298
- arviz/plots/ppcplot.py +0 -369
- arviz/plots/rankplot.py +0 -232
- arviz/plots/separationplot.py +0 -167
- arviz/plots/styles/arviz-bluish.mplstyle +0 -1
- arviz/plots/styles/arviz-brownish.mplstyle +0 -1
- arviz/plots/styles/arviz-colors.mplstyle +0 -2
- arviz/plots/styles/arviz-cyanish.mplstyle +0 -1
- arviz/plots/styles/arviz-darkgrid.mplstyle +0 -40
- arviz/plots/styles/arviz-doc.mplstyle +0 -88
- arviz/plots/styles/arviz-docgrid.mplstyle +0 -88
- arviz/plots/styles/arviz-grayscale.mplstyle +0 -41
- arviz/plots/styles/arviz-greenish.mplstyle +0 -1
- arviz/plots/styles/arviz-orangish.mplstyle +0 -1
- arviz/plots/styles/arviz-plasmish.mplstyle +0 -1
- arviz/plots/styles/arviz-purplish.mplstyle +0 -1
- arviz/plots/styles/arviz-redish.mplstyle +0 -1
- arviz/plots/styles/arviz-royish.mplstyle +0 -1
- arviz/plots/styles/arviz-viridish.mplstyle +0 -1
- arviz/plots/styles/arviz-white.mplstyle +0 -40
- arviz/plots/styles/arviz-whitegrid.mplstyle +0 -40
- arviz/plots/traceplot.py +0 -273
- arviz/plots/tsplot.py +0 -440
- arviz/plots/violinplot.py +0 -192
- arviz/preview.py +0 -58
- arviz/py.typed +0 -0
- arviz/rcparams.py +0 -606
- arviz/sel_utils.py +0 -223
- arviz/static/css/style.css +0 -340
- arviz/static/html/icons-svg-inline.html +0 -15
- arviz/stats/__init__.py +0 -37
- arviz/stats/density_utils.py +0 -1013
- arviz/stats/diagnostics.py +0 -1013
- arviz/stats/ecdf_utils.py +0 -324
- arviz/stats/stats.py +0 -2422
- arviz/stats/stats_refitting.py +0 -119
- arviz/stats/stats_utils.py +0 -609
- arviz/tests/__init__.py +0 -1
- arviz/tests/base_tests/__init__.py +0 -1
- arviz/tests/base_tests/test_data.py +0 -1679
- arviz/tests/base_tests/test_data_zarr.py +0 -143
- arviz/tests/base_tests/test_diagnostics.py +0 -511
- arviz/tests/base_tests/test_diagnostics_numba.py +0 -87
- arviz/tests/base_tests/test_helpers.py +0 -18
- arviz/tests/base_tests/test_labels.py +0 -69
- arviz/tests/base_tests/test_plot_utils.py +0 -342
- arviz/tests/base_tests/test_plots_bokeh.py +0 -1288
- arviz/tests/base_tests/test_plots_matplotlib.py +0 -2197
- arviz/tests/base_tests/test_rcparams.py +0 -317
- arviz/tests/base_tests/test_stats.py +0 -925
- arviz/tests/base_tests/test_stats_ecdf_utils.py +0 -166
- arviz/tests/base_tests/test_stats_numba.py +0 -45
- arviz/tests/base_tests/test_stats_utils.py +0 -384
- arviz/tests/base_tests/test_utils.py +0 -376
- arviz/tests/base_tests/test_utils_numba.py +0 -87
- arviz/tests/conftest.py +0 -46
- arviz/tests/external_tests/__init__.py +0 -1
- arviz/tests/external_tests/test_data_beanmachine.py +0 -78
- arviz/tests/external_tests/test_data_cmdstan.py +0 -398
- arviz/tests/external_tests/test_data_cmdstanpy.py +0 -496
- arviz/tests/external_tests/test_data_emcee.py +0 -166
- arviz/tests/external_tests/test_data_numpyro.py +0 -434
- arviz/tests/external_tests/test_data_pyjags.py +0 -119
- arviz/tests/external_tests/test_data_pyro.py +0 -260
- arviz/tests/external_tests/test_data_pystan.py +0 -307
- arviz/tests/helpers.py +0 -677
- arviz/utils.py +0 -773
- arviz/wrappers/__init__.py +0 -13
- arviz/wrappers/base.py +0 -236
- arviz/wrappers/wrap_pymc.py +0 -36
- arviz/wrappers/wrap_stan.py +0 -148
- arviz-0.23.3.dist-info/METADATA +0 -264
- arviz-0.23.3.dist-info/RECORD +0 -183
- arviz-0.23.3.dist-info/top_level.txt +0 -1
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"""Bokeh dotplot."""
|
|
2
|
-
|
|
3
|
-
import math
|
|
4
|
-
import warnings
|
|
5
|
-
import numpy as np
|
|
6
|
-
|
|
7
|
-
from ...plot_utils import _scale_fig_size, vectorized_to_hex
|
|
8
|
-
from .. import show_layout
|
|
9
|
-
from . import create_axes_grid
|
|
10
|
-
from ...plot_utils import plot_point_interval
|
|
11
|
-
from ...dotplot import wilkinson_algorithm, layout_stacks
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def plot_dot(
|
|
15
|
-
values,
|
|
16
|
-
binwidth,
|
|
17
|
-
dotsize,
|
|
18
|
-
stackratio,
|
|
19
|
-
hdi_prob,
|
|
20
|
-
quartiles,
|
|
21
|
-
rotated,
|
|
22
|
-
dotcolor,
|
|
23
|
-
intervalcolor,
|
|
24
|
-
markersize,
|
|
25
|
-
markercolor,
|
|
26
|
-
marker,
|
|
27
|
-
figsize,
|
|
28
|
-
linewidth,
|
|
29
|
-
point_estimate,
|
|
30
|
-
nquantiles,
|
|
31
|
-
point_interval,
|
|
32
|
-
ax,
|
|
33
|
-
show,
|
|
34
|
-
backend_kwargs,
|
|
35
|
-
plot_kwargs,
|
|
36
|
-
):
|
|
37
|
-
"""Bokeh dotplot."""
|
|
38
|
-
if backend_kwargs is None:
|
|
39
|
-
backend_kwargs = {}
|
|
40
|
-
|
|
41
|
-
backend_kwargs.setdefault("match_aspect", True)
|
|
42
|
-
|
|
43
|
-
(figsize, _, _, _, auto_linewidth, auto_markersize) = _scale_fig_size(figsize, None)
|
|
44
|
-
dotcolor = vectorized_to_hex(dotcolor)
|
|
45
|
-
intervalcolor = vectorized_to_hex(intervalcolor)
|
|
46
|
-
markercolor = vectorized_to_hex(markercolor)
|
|
47
|
-
|
|
48
|
-
if plot_kwargs is None:
|
|
49
|
-
plot_kwargs = {}
|
|
50
|
-
else:
|
|
51
|
-
plot_kwargs = plot_kwargs.copy()
|
|
52
|
-
plot_kwargs.setdefault("color", dotcolor)
|
|
53
|
-
plot_kwargs.setdefault("marker", "circle")
|
|
54
|
-
|
|
55
|
-
if linewidth is None:
|
|
56
|
-
linewidth = auto_linewidth
|
|
57
|
-
|
|
58
|
-
if markersize is None:
|
|
59
|
-
markersize = auto_markersize
|
|
60
|
-
|
|
61
|
-
if ax is None:
|
|
62
|
-
ax = create_axes_grid(
|
|
63
|
-
1,
|
|
64
|
-
figsize=figsize,
|
|
65
|
-
squeeze=True,
|
|
66
|
-
backend_kwargs=backend_kwargs,
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
if point_interval:
|
|
70
|
-
ax = plot_point_interval(
|
|
71
|
-
ax,
|
|
72
|
-
values,
|
|
73
|
-
point_estimate,
|
|
74
|
-
hdi_prob,
|
|
75
|
-
quartiles,
|
|
76
|
-
linewidth,
|
|
77
|
-
markersize,
|
|
78
|
-
markercolor,
|
|
79
|
-
marker,
|
|
80
|
-
rotated,
|
|
81
|
-
intervalcolor,
|
|
82
|
-
"bokeh",
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
if nquantiles > values.shape[0]:
|
|
86
|
-
warnings.warn(
|
|
87
|
-
"nquantiles must be less than or equal to the number of data points", UserWarning
|
|
88
|
-
)
|
|
89
|
-
nquantiles = values.shape[0]
|
|
90
|
-
else:
|
|
91
|
-
qlist = np.linspace(1 / (2 * nquantiles), 1 - 1 / (2 * nquantiles), nquantiles)
|
|
92
|
-
values = np.quantile(values, qlist)
|
|
93
|
-
|
|
94
|
-
if binwidth is None:
|
|
95
|
-
binwidth = math.sqrt((values[-1] - values[0] + 1) ** 2 / (2 * nquantiles * np.pi))
|
|
96
|
-
|
|
97
|
-
## Wilkinson's Algorithm
|
|
98
|
-
stack_locs, stack_count = wilkinson_algorithm(values, binwidth)
|
|
99
|
-
x, y = layout_stacks(stack_locs, stack_count, binwidth, stackratio, rotated)
|
|
100
|
-
|
|
101
|
-
ax.scatter(x, y, radius=dotsize * (binwidth / 2), **plot_kwargs, radius_dimension="y")
|
|
102
|
-
if rotated:
|
|
103
|
-
ax.xaxis.major_tick_line_color = None
|
|
104
|
-
ax.xaxis.minor_tick_line_color = None
|
|
105
|
-
ax.xaxis.major_label_text_font_size = "0pt"
|
|
106
|
-
else:
|
|
107
|
-
ax.yaxis.major_tick_line_color = None
|
|
108
|
-
ax.yaxis.minor_tick_line_color = None
|
|
109
|
-
ax.yaxis.major_label_text_font_size = "0pt"
|
|
110
|
-
|
|
111
|
-
show_layout(ax, show)
|
|
112
|
-
|
|
113
|
-
return ax
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"""Bokeh ecdfplot."""
|
|
2
|
-
|
|
3
|
-
from matplotlib.colors import to_hex
|
|
4
|
-
|
|
5
|
-
from ...plot_utils import _scale_fig_size
|
|
6
|
-
from .. import show_layout
|
|
7
|
-
from . import backend_kwarg_defaults, create_axes_grid
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def plot_ecdf(
|
|
11
|
-
x_coord,
|
|
12
|
-
y_coord,
|
|
13
|
-
x_bands,
|
|
14
|
-
lower,
|
|
15
|
-
higher,
|
|
16
|
-
plot_kwargs,
|
|
17
|
-
fill_kwargs,
|
|
18
|
-
plot_outline_kwargs,
|
|
19
|
-
figsize,
|
|
20
|
-
fill_band,
|
|
21
|
-
ax,
|
|
22
|
-
show,
|
|
23
|
-
backend_kwargs,
|
|
24
|
-
):
|
|
25
|
-
"""Bokeh ecdfplot."""
|
|
26
|
-
if backend_kwargs is None:
|
|
27
|
-
backend_kwargs = {}
|
|
28
|
-
|
|
29
|
-
backend_kwargs = {
|
|
30
|
-
**backend_kwarg_defaults(),
|
|
31
|
-
**backend_kwargs,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
(figsize, *_) = _scale_fig_size(figsize, None)
|
|
35
|
-
|
|
36
|
-
if ax is None:
|
|
37
|
-
ax = create_axes_grid(
|
|
38
|
-
1,
|
|
39
|
-
figsize=figsize,
|
|
40
|
-
squeeze=True,
|
|
41
|
-
backend_kwargs=backend_kwargs,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
if plot_kwargs is None:
|
|
45
|
-
plot_kwargs = {}
|
|
46
|
-
|
|
47
|
-
plot_kwargs.setdefault("mode", "after")
|
|
48
|
-
|
|
49
|
-
if fill_band:
|
|
50
|
-
if fill_kwargs is None:
|
|
51
|
-
fill_kwargs = {}
|
|
52
|
-
fill_kwargs.setdefault("fill_color", to_hex("C0"))
|
|
53
|
-
fill_kwargs.setdefault("fill_alpha", 0.2)
|
|
54
|
-
else:
|
|
55
|
-
if plot_outline_kwargs is None:
|
|
56
|
-
plot_outline_kwargs = {}
|
|
57
|
-
plot_outline_kwargs.setdefault("color", to_hex("C0"))
|
|
58
|
-
plot_outline_kwargs.setdefault("alpha", 0.2)
|
|
59
|
-
|
|
60
|
-
if x_bands is not None:
|
|
61
|
-
ax.step(x_coord, y_coord, **plot_kwargs)
|
|
62
|
-
|
|
63
|
-
if fill_band:
|
|
64
|
-
ax.varea(x_bands, lower, higher, **fill_kwargs)
|
|
65
|
-
else:
|
|
66
|
-
ax.line(x_bands, lower, **plot_outline_kwargs)
|
|
67
|
-
ax.line(x_bands, higher, **plot_outline_kwargs)
|
|
68
|
-
else:
|
|
69
|
-
ax.step(x_coord, y_coord, **plot_kwargs)
|
|
70
|
-
|
|
71
|
-
show_layout(ax, show)
|
|
72
|
-
|
|
73
|
-
return ax
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"""Bokeh ELPDPlot."""
|
|
2
|
-
|
|
3
|
-
import warnings
|
|
4
|
-
|
|
5
|
-
import bokeh.plotting as bkp
|
|
6
|
-
import numpy as np
|
|
7
|
-
from bokeh.models import ColumnDataSource
|
|
8
|
-
from bokeh.models.annotations import Title
|
|
9
|
-
from bokeh.models.glyphs import Scatter
|
|
10
|
-
from ....rcparams import _validate_bokeh_marker, rcParams
|
|
11
|
-
from ...plot_utils import _scale_fig_size, color_from_dim, vectorized_to_hex
|
|
12
|
-
from .. import show_layout
|
|
13
|
-
from . import backend_kwarg_defaults, create_axes_grid
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def plot_elpd(
|
|
17
|
-
ax,
|
|
18
|
-
models,
|
|
19
|
-
pointwise_data,
|
|
20
|
-
numvars,
|
|
21
|
-
figsize,
|
|
22
|
-
textsize,
|
|
23
|
-
plot_kwargs,
|
|
24
|
-
xlabels,
|
|
25
|
-
coord_labels,
|
|
26
|
-
xdata,
|
|
27
|
-
threshold,
|
|
28
|
-
legend, # pylint: disable=unused-argument
|
|
29
|
-
color,
|
|
30
|
-
backend_kwargs,
|
|
31
|
-
show,
|
|
32
|
-
):
|
|
33
|
-
"""Bokeh elpd plot."""
|
|
34
|
-
if backend_kwargs is None:
|
|
35
|
-
backend_kwargs = {}
|
|
36
|
-
|
|
37
|
-
backend_kwargs = {
|
|
38
|
-
**backend_kwarg_defaults(
|
|
39
|
-
("dpi", "plot.bokeh.figure.dpi"),
|
|
40
|
-
),
|
|
41
|
-
**backend_kwargs,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
plot_kwargs = {} if plot_kwargs is None else plot_kwargs
|
|
45
|
-
plot_kwargs.setdefault("marker", rcParams["plot.bokeh.marker"])
|
|
46
|
-
if isinstance(color, str) and color in pointwise_data[0].dims:
|
|
47
|
-
colors, _ = color_from_dim(pointwise_data[0], color)
|
|
48
|
-
plot_kwargs.setdefault("color", vectorized_to_hex(colors))
|
|
49
|
-
plot_kwargs.setdefault("color", vectorized_to_hex(color))
|
|
50
|
-
|
|
51
|
-
# flatten data (data must be flattened after selecting, labeling and coloring)
|
|
52
|
-
pointwise_data = [pointwise.values.flatten() for pointwise in pointwise_data]
|
|
53
|
-
|
|
54
|
-
if numvars == 2:
|
|
55
|
-
(figsize, _, _, _, _, markersize) = _scale_fig_size(
|
|
56
|
-
figsize, textsize, numvars - 1, numvars - 1
|
|
57
|
-
)
|
|
58
|
-
plot_kwargs.setdefault("s", markersize)
|
|
59
|
-
|
|
60
|
-
if ax is None:
|
|
61
|
-
ax = create_axes_grid(
|
|
62
|
-
1,
|
|
63
|
-
figsize=figsize,
|
|
64
|
-
squeeze=True,
|
|
65
|
-
backend_kwargs=backend_kwargs,
|
|
66
|
-
)
|
|
67
|
-
ydata = pointwise_data[0] - pointwise_data[1]
|
|
68
|
-
_plot_atomic_elpd(
|
|
69
|
-
ax, xdata, ydata, *models, threshold, coord_labels, xlabels, True, True, plot_kwargs
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
else:
|
|
73
|
-
max_plots = (
|
|
74
|
-
numvars**2 if rcParams["plot.max_subplots"] is None else rcParams["plot.max_subplots"]
|
|
75
|
-
)
|
|
76
|
-
vars_to_plot = np.sum(np.arange(numvars).cumsum() < max_plots)
|
|
77
|
-
if vars_to_plot < numvars:
|
|
78
|
-
warnings.warn(
|
|
79
|
-
"rcParams['plot.max_subplots'] ({max_plots}) is smaller than the number "
|
|
80
|
-
"of resulting ELPD pairwise plots with these variables, generating only a "
|
|
81
|
-
"{side}x{side} grid".format(max_plots=max_plots, side=vars_to_plot),
|
|
82
|
-
UserWarning,
|
|
83
|
-
)
|
|
84
|
-
numvars = vars_to_plot
|
|
85
|
-
|
|
86
|
-
(figsize, _, _, _, _, markersize) = _scale_fig_size(
|
|
87
|
-
figsize, textsize, numvars - 2, numvars - 2
|
|
88
|
-
)
|
|
89
|
-
plot_kwargs.setdefault("s", markersize)
|
|
90
|
-
|
|
91
|
-
if ax is None:
|
|
92
|
-
dpi = backend_kwargs.pop("dpi")
|
|
93
|
-
ax = []
|
|
94
|
-
for row in range(numvars - 1):
|
|
95
|
-
ax_row = []
|
|
96
|
-
for col in range(numvars - 1):
|
|
97
|
-
if row == 0 and col == 0:
|
|
98
|
-
ax_first = bkp.figure(
|
|
99
|
-
width=int(figsize[0] / (numvars - 1) * dpi),
|
|
100
|
-
height=int(figsize[1] / (numvars - 1) * dpi),
|
|
101
|
-
**backend_kwargs,
|
|
102
|
-
)
|
|
103
|
-
ax_row.append(ax_first)
|
|
104
|
-
elif row < col:
|
|
105
|
-
ax_row.append(None)
|
|
106
|
-
else:
|
|
107
|
-
ax_row.append(
|
|
108
|
-
bkp.figure(
|
|
109
|
-
width=int(figsize[0] / (numvars - 1) * dpi),
|
|
110
|
-
height=int(figsize[1] / (numvars - 1) * dpi),
|
|
111
|
-
x_range=ax_first.x_range,
|
|
112
|
-
y_range=ax_first.y_range,
|
|
113
|
-
**backend_kwargs,
|
|
114
|
-
)
|
|
115
|
-
)
|
|
116
|
-
ax.append(ax_row)
|
|
117
|
-
ax = np.array(ax)
|
|
118
|
-
|
|
119
|
-
for i in range(0, numvars - 1):
|
|
120
|
-
var1 = pointwise_data[i]
|
|
121
|
-
|
|
122
|
-
for j in range(0, numvars - 1):
|
|
123
|
-
if j < i:
|
|
124
|
-
continue
|
|
125
|
-
|
|
126
|
-
var2 = pointwise_data[j + 1]
|
|
127
|
-
ydata = var1 - var2
|
|
128
|
-
_plot_atomic_elpd(
|
|
129
|
-
ax[j, i],
|
|
130
|
-
xdata,
|
|
131
|
-
ydata,
|
|
132
|
-
models[i],
|
|
133
|
-
models[j + 1],
|
|
134
|
-
threshold,
|
|
135
|
-
coord_labels,
|
|
136
|
-
xlabels,
|
|
137
|
-
j == numvars - 2,
|
|
138
|
-
i == 0,
|
|
139
|
-
plot_kwargs,
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
show_layout(ax, show)
|
|
143
|
-
|
|
144
|
-
return ax
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def _plot_atomic_elpd(
|
|
148
|
-
ax_,
|
|
149
|
-
xdata,
|
|
150
|
-
ydata,
|
|
151
|
-
model1,
|
|
152
|
-
model2,
|
|
153
|
-
threshold,
|
|
154
|
-
coord_labels,
|
|
155
|
-
xlabels,
|
|
156
|
-
xlabels_shown,
|
|
157
|
-
ylabels_shown,
|
|
158
|
-
plot_kwargs,
|
|
159
|
-
):
|
|
160
|
-
marker = _validate_bokeh_marker(plot_kwargs.get("marker"))
|
|
161
|
-
sizes = np.ones(len(xdata)) * plot_kwargs.get("s")
|
|
162
|
-
glyph = Scatter(
|
|
163
|
-
x="xdata",
|
|
164
|
-
y="ydata",
|
|
165
|
-
size="sizes",
|
|
166
|
-
line_color=plot_kwargs.get("color", "black"),
|
|
167
|
-
marker=marker,
|
|
168
|
-
)
|
|
169
|
-
source = ColumnDataSource(dict(xdata=xdata, ydata=ydata, sizes=sizes))
|
|
170
|
-
ax_.add_glyph(source, glyph)
|
|
171
|
-
if threshold is not None:
|
|
172
|
-
diff_abs = np.abs(ydata - ydata.mean())
|
|
173
|
-
bool_ary = diff_abs > threshold * ydata.std()
|
|
174
|
-
if coord_labels is None:
|
|
175
|
-
coord_labels = xdata.astype(str)
|
|
176
|
-
outliers = np.nonzero(bool_ary)[0]
|
|
177
|
-
for outlier in outliers:
|
|
178
|
-
label = coord_labels[outlier]
|
|
179
|
-
ax_.text(
|
|
180
|
-
x=[outlier],
|
|
181
|
-
y=[ydata[outlier]],
|
|
182
|
-
text=label,
|
|
183
|
-
text_color="black",
|
|
184
|
-
)
|
|
185
|
-
if ylabels_shown:
|
|
186
|
-
ax_.yaxis.axis_label = "ELPD difference"
|
|
187
|
-
else:
|
|
188
|
-
ax_.yaxis.minor_tick_line_color = None
|
|
189
|
-
ax_.yaxis.major_label_text_font_size = "0pt"
|
|
190
|
-
|
|
191
|
-
if xlabels_shown:
|
|
192
|
-
if xlabels:
|
|
193
|
-
ax_.xaxis.ticker = np.arange(0, len(coord_labels))
|
|
194
|
-
ax_.xaxis.major_label_overrides = {
|
|
195
|
-
str(key): str(value)
|
|
196
|
-
for key, value in zip(np.arange(0, len(coord_labels)), list(coord_labels))
|
|
197
|
-
}
|
|
198
|
-
else:
|
|
199
|
-
ax_.xaxis.minor_tick_line_color = None
|
|
200
|
-
ax_.xaxis.major_label_text_font_size = "0pt"
|
|
201
|
-
title = Title()
|
|
202
|
-
title.text = f"{model1} - {model2}"
|
|
203
|
-
ax_.title = title
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"""Bokeh energyplot."""
|
|
2
|
-
|
|
3
|
-
from itertools import cycle
|
|
4
|
-
|
|
5
|
-
import numpy as np
|
|
6
|
-
from bokeh.models import Label
|
|
7
|
-
from bokeh.models.annotations import Legend
|
|
8
|
-
from matplotlib.pyplot import rcParams as mpl_rcParams
|
|
9
|
-
|
|
10
|
-
from ....stats import bfmi as e_bfmi
|
|
11
|
-
from ...kdeplot import plot_kde
|
|
12
|
-
from ...plot_utils import _scale_fig_size, vectorized_to_hex
|
|
13
|
-
from .. import show_layout
|
|
14
|
-
from . import backend_kwarg_defaults, create_axes_grid
|
|
15
|
-
from .distplot import _histplot_bokeh_op
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def plot_energy(
|
|
19
|
-
ax,
|
|
20
|
-
energy,
|
|
21
|
-
kind,
|
|
22
|
-
bfmi,
|
|
23
|
-
figsize,
|
|
24
|
-
textsize,
|
|
25
|
-
fill_alpha,
|
|
26
|
-
fill_color,
|
|
27
|
-
fill_kwargs,
|
|
28
|
-
plot_kwargs,
|
|
29
|
-
bw,
|
|
30
|
-
legend,
|
|
31
|
-
backend_kwargs,
|
|
32
|
-
show,
|
|
33
|
-
):
|
|
34
|
-
"""Bokeh energy plot."""
|
|
35
|
-
if backend_kwargs is None:
|
|
36
|
-
backend_kwargs = {}
|
|
37
|
-
|
|
38
|
-
backend_kwargs = {
|
|
39
|
-
**backend_kwarg_defaults(("dpi", "plot.bokeh.figure.dpi")),
|
|
40
|
-
**backend_kwargs,
|
|
41
|
-
}
|
|
42
|
-
dpi = backend_kwargs.pop("dpi")
|
|
43
|
-
|
|
44
|
-
figsize, _, _, _, line_width, _ = _scale_fig_size(figsize, textsize, 1, 1)
|
|
45
|
-
|
|
46
|
-
fill_kwargs = {} if fill_kwargs is None else fill_kwargs
|
|
47
|
-
plot_kwargs = {} if plot_kwargs is None else plot_kwargs
|
|
48
|
-
plot_kwargs.setdefault("line_width", line_width)
|
|
49
|
-
if kind == "hist":
|
|
50
|
-
legend = False
|
|
51
|
-
|
|
52
|
-
if ax is None:
|
|
53
|
-
ax = create_axes_grid(
|
|
54
|
-
1,
|
|
55
|
-
figsize=figsize,
|
|
56
|
-
squeeze=True,
|
|
57
|
-
backend_kwargs=backend_kwargs,
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
_colors = [
|
|
61
|
-
prop for _, prop in zip(range(10), cycle(mpl_rcParams["axes.prop_cycle"].by_key()["color"]))
|
|
62
|
-
]
|
|
63
|
-
if (fill_color[0].startswith("C") and len(fill_color[0]) == 2) and (
|
|
64
|
-
fill_color[1].startswith("C") and len(fill_color[1]) == 2
|
|
65
|
-
):
|
|
66
|
-
fill_color = tuple((_colors[int(color[1:]) % 10] for color in fill_color))
|
|
67
|
-
elif fill_color[0].startswith("C") and len(fill_color[0]) == 2:
|
|
68
|
-
fill_color = tuple([_colors[int(fill_color[0][1:]) % 10]] + list(fill_color[1:]))
|
|
69
|
-
elif fill_color[1].startswith("C") and len(fill_color[1]) == 2:
|
|
70
|
-
fill_color = tuple(list(fill_color[1:]) + [_colors[int(fill_color[0][1:]) % 10]])
|
|
71
|
-
|
|
72
|
-
series = zip(
|
|
73
|
-
fill_alpha,
|
|
74
|
-
fill_color,
|
|
75
|
-
("Marginal Energy", "Energy transition"),
|
|
76
|
-
(energy - energy.mean(), np.diff(energy)),
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
labels = []
|
|
80
|
-
|
|
81
|
-
if kind == "kde":
|
|
82
|
-
for alpha, color, label, value in series:
|
|
83
|
-
fill_kwargs["fill_alpha"] = alpha
|
|
84
|
-
fill_kwargs["fill_color"] = vectorized_to_hex(color)
|
|
85
|
-
plot_kwargs["line_alpha"] = alpha
|
|
86
|
-
plot_kwargs["line_color"] = vectorized_to_hex(color)
|
|
87
|
-
_, glyph = plot_kde(
|
|
88
|
-
value,
|
|
89
|
-
bw=bw,
|
|
90
|
-
label=label,
|
|
91
|
-
fill_kwargs=fill_kwargs,
|
|
92
|
-
plot_kwargs=plot_kwargs,
|
|
93
|
-
ax=ax,
|
|
94
|
-
legend=legend,
|
|
95
|
-
backend="bokeh",
|
|
96
|
-
backend_kwargs={},
|
|
97
|
-
show=False,
|
|
98
|
-
return_glyph=True,
|
|
99
|
-
)
|
|
100
|
-
labels.append(
|
|
101
|
-
(
|
|
102
|
-
label,
|
|
103
|
-
glyph,
|
|
104
|
-
)
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
elif kind == "hist":
|
|
108
|
-
hist_kwargs = plot_kwargs.copy()
|
|
109
|
-
hist_kwargs.update(**fill_kwargs)
|
|
110
|
-
|
|
111
|
-
for alpha, color, label, value in series:
|
|
112
|
-
hist_kwargs["fill_alpha"] = alpha
|
|
113
|
-
hist_kwargs["fill_color"] = vectorized_to_hex(color)
|
|
114
|
-
hist_kwargs["line_color"] = None
|
|
115
|
-
hist_kwargs["line_alpha"] = alpha
|
|
116
|
-
_histplot_bokeh_op(
|
|
117
|
-
value.flatten(),
|
|
118
|
-
values2=None,
|
|
119
|
-
rotated=False,
|
|
120
|
-
ax=ax,
|
|
121
|
-
hist_kwargs=hist_kwargs,
|
|
122
|
-
is_circular=False,
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
else:
|
|
126
|
-
raise ValueError(f"Plot type {kind} not recognized.")
|
|
127
|
-
|
|
128
|
-
if bfmi:
|
|
129
|
-
for idx, val in enumerate(e_bfmi(energy)):
|
|
130
|
-
bfmi_info = Label(
|
|
131
|
-
x=int(figsize[0] * dpi * 0.58),
|
|
132
|
-
y=int(figsize[1] * dpi * 0.73) - 20 * idx,
|
|
133
|
-
x_units="screen",
|
|
134
|
-
y_units="screen",
|
|
135
|
-
text=f"chain {idx:>2} BFMI = {val:.2f}",
|
|
136
|
-
border_line_color=None,
|
|
137
|
-
border_line_alpha=0.0,
|
|
138
|
-
background_fill_color="white",
|
|
139
|
-
background_fill_alpha=1.0,
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
ax.add_layout(bfmi_info)
|
|
143
|
-
|
|
144
|
-
if legend and label is not None:
|
|
145
|
-
legend = Legend(
|
|
146
|
-
items=labels,
|
|
147
|
-
location="center_right",
|
|
148
|
-
orientation="horizontal",
|
|
149
|
-
)
|
|
150
|
-
ax.add_layout(legend, "above")
|
|
151
|
-
ax.legend.click_policy = "hide"
|
|
152
|
-
|
|
153
|
-
show_layout(ax, show)
|
|
154
|
-
|
|
155
|
-
return ax
|