Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
rug_kwargs,
contour_kwargs,
contourf_kwargs,
pcolormesh_kwargs,
hist_kwargs,
ax,
backend_kwargs,
show,
**kwargs # pylint: disable=unused-argument
):
"""Bokeh distplot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(
("tools", "plot.bokeh.tools"),
("output_backend", "plot.bokeh.output_backend"),
("width", "plot.bokeh.figure.width"),
("height", "plot.bokeh.figure.height"),
),
**backend_kwargs,
}
if ax is None:
ax = bkp.figure(**backend_kwargs)
if kind == "auto":
kind = "hist" if values.dtype.kind == "i" else "kde"
if kind == "hist":
_histplot_bokeh_op(
values=values, values2=values2, rotated=rotated, ax=ax, hist_kwargs=hist_kwargs
figsize,
plotters,
bins,
kind,
colors,
ref_line,
labels,
backend_kwargs,
show,
):
"""Bokeh rank plot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(),
**backend_kwargs,
}
if axes is None:
_, axes = _create_axes_grid(
length_plotters,
rows,
cols,
figsize=figsize,
squeeze=False,
sharex=True,
sharey=True,
backend="bokeh",
backend_kwargs=backend_kwargs,
)
for ax, (var_name, selection, var_data) in zip(np.ravel(axes), plotters):
markersize,
credible_interval,
point_estimate,
hpd_markers,
outline,
shade,
data_labels,
backend_kwargs,
show,
):
"""Bokeh density plot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(),
**backend_kwargs,
}
_, ax = _create_axes_grid(
length_plotters,
rows,
cols,
figsize=figsize,
squeeze=False,
backend="bokeh",
backend_kwargs=backend_kwargs,
)
axis_map = {label: ax_ for label, ax_ in zip(all_labels, ax.flatten())}
if data_labels is None:
data_labels = {}
def plot_hpd(ax, x_data, y_data, plot_kwargs, fill_kwargs, backend_kwargs, show):
"""Bokeh hpd plot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(
("tools", "plot.bokeh.tools"),
("output_backend", "plot.bokeh.output_backend"),
("width", "plot.bokeh.figure.width"),
("height", "plot.bokeh.figure.height"),
),
**backend_kwargs,
}
if ax is None:
ax = bkp.figure(**backend_kwargs)
color = plot_kwargs.pop("color")
if len(color) == 2 and color[0] == "C":
color = [
prop
for _, prop in zip(
range(int(color[1:])), cycle(mpl_rcParams["axes.prop_cycle"].by_key()["color"])
textsize,
plot_kwargs,
markersize,
xlabels,
coord_labels,
xdata,
threshold,
backend_kwargs,
show,
):
"""Bokeh elpd plot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(
("tools", "plot.bokeh.tools"),
("output_backend", "plot.bokeh.output_backend"),
("dpi", "plot.bokeh.figure.dpi"),
),
**backend_kwargs,
}
dpi = backend_kwargs.pop("dpi")
if numvars == 2:
(figsize, _, _, _, _, markersize) = _scale_fig_size(
figsize, textsize, numvars - 1, numvars - 1
)
plot_kwargs.setdefault("s", markersize)
if ax is None:
ax = bkp.figure(
width=int(figsize[0] * dpi), height=int(figsize[1] * dpi), **backend_kwargs
unif_densities,
hpd_kwargs,
n_unif,
unif,
plot_unif_kwargs,
loo_pit_kde,
plot_kwargs,
backend_kwargs,
show,
):
"""Bokeh loo pit plot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(
("tools", "plot.bokeh.tools"),
("output_backend", "plot.bokeh.output_backend"),
("dpi", "plot.bokeh.figure.dpi"),
),
**backend_kwargs,
}
dpi = backend_kwargs.pop("dpi")
if ax is None:
ax = bkp.figure(width=int(figsize[0] * dpi), height=int(figsize[1] * dpi), **backend_kwargs)
if ecdf:
if plot_kwargs.get("drawstyle") == "steps-mid":
ax.step(
np.hstack((0, loo_pit, 1)),
np.hstack((0, loo_pit - loo_pit_ecdf, 0)),
line_color=plot_kwargs.get("color", "black"),
def plot_autocorr(
axes, plotters, max_lag, figsize, rows, cols, line_width, combined, backend_kwargs, show,
):
"""Bokeh autocorrelation plot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(),
**backend_kwargs,
}
if axes is None:
_, axes = _create_axes_grid(
len(plotters),
rows,
cols,
figsize=figsize,
squeeze=False,
sharex=True,
sharey=True,
backend="bokeh",
backend_kwargs=backend_kwargs,
)
def plot_parallel(ax, diverging_mask, _posterior, var_names, figsize, backend_kwargs, show):
"""Bokeh parallel plot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(
("tools", "plot.bokeh.tools"),
("output_backend", "plot.bokeh.output_backend"),
("dpi", "plot.bokeh.figure.dpi"),
),
**backend_kwargs,
}
dpi = backend_kwargs.pop("dpi")
if ax is None:
ax = bkp.figure(width=int(figsize[0] * dpi), height=int(figsize[1] * dpi), **backend_kwargs)
non_div = list(_posterior[:, ~diverging_mask].T)
x_non_div = [list(range(len(non_div[0]))) for _ in range(len(non_div))]
ax.multi_line(
x_non_div, non_div, line_color="black", line_alpha=0.05,
)
fill_kwargs,
rug_kwargs,
contour_kwargs,
contourf_kwargs,
pcolormesh_kwargs,
ax,
legend,
backend_kwargs,
show,
):
"""Bokeh kde plot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(
("tools", "plot.bokeh.tools"),
("output_backend", "plot.bokeh.output_backend"),
("width", "plot.bokeh.figure.width"),
("height", "plot.bokeh.figure.height"),
),
**backend_kwargs,
}
if ax is None:
ax = bkp.figure(**backend_kwargs)
if legend and label is not None:
plot_kwargs["legend_label"] = label
if values2 is None:
if plot_kwargs is None:
plot_kwargs = {}
kind,
plot_kwargs,
contour,
fill_last,
divergences,
diverging_mask,
flat_var_names,
backend_kwargs,
show,
):
"""Bokeh pair plot."""
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(
("tools", "plot.bokeh.tools"),
("output_backend", "plot.bokeh.output_backend"),
("dpi", "plot.bokeh.figure.dpi"),
),
**backend_kwargs,
}
dpi = backend_kwargs.pop("dpi")
if numvars == 2:
(figsize, _, _, _, _, _) = _scale_fig_size(figsize, textsize, numvars - 1, numvars - 1)
source_dict = dict(zip(flat_var_names, [list(post) for post in _posterior]))
if divergences:
divergenve_name = "divergences_{}".format(str(uuid4()))
source_dict[divergenve_name] = (
np.array(diverging_mask).astype(bool).astype(int).astype(str)