Skip to content

Commit

Permalink
Merge dea8432 into dfd353d
Browse files Browse the repository at this point in the history
  • Loading branch information
canyon289 committed Dec 14, 2019
2 parents dfd353d + dea8432 commit b9d02ea
Show file tree
Hide file tree
Showing 75 changed files with 568 additions and 565 deletions.
6 changes: 5 additions & 1 deletion .pylintrc
Expand Up @@ -67,7 +67,11 @@ disable=missing-docstring,
import-outside-toplevel,
no-else-continue,
unnecessary-comprehension,
unsubscriptable-object
unsubscriptable-object,
cyclic-import,

#TODO: Remove this once todos are done
fixme


# Enable the message, report, category or checker with the given id(s). You can
Expand Down
1 change: 1 addition & 0 deletions arviz/data/io_numpyro.py
@@ -1,3 +1,4 @@
# pylint: disable=cyclic-import
"""NumPyro-specific conversion code."""
import logging
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions arviz/data/io_pyro.py
@@ -1,3 +1,4 @@
# pylint: disable=cyclic-import
"""Pyro-specific conversion code."""
import logging
import numpy as np
Expand Down
11 changes: 4 additions & 7 deletions arviz/plots/autocorrplot.py
@@ -1,14 +1,14 @@
"""Autocorrelation plot of data."""
import numpy as np

from .backends import check_bokeh_version
from ..data import convert_to_dataset
from .plot_utils import (
_scale_fig_size,
default_grid,
xarray_var_iter,
_create_axes_grid,
filter_plotters_list,
get_plotting_method,
)
from ..utils import _var_names

Expand Down Expand Up @@ -136,17 +136,14 @@ def plot_autocorr(
)

if backend == "bokeh":
check_bokeh_version()
from .backends.bokeh.bokeh_autocorrplot import _plot_autocorr

autocorr_plot_args.pop("xt_labelsize")
autocorr_plot_args.pop("titlesize")
autocorr_plot_args["line_width"] = autocorr_plot_args.pop("linewidth")
autocorr_plot_args["show"] = show
axes = _plot_autocorr(**autocorr_plot_args) # pylint: disable=unexpected-keyword-arg
else:
from .backends.matplotlib.mpl_autocorrplot import _plot_autocorr

axes = _plot_autocorr(**autocorr_plot_args)
# TODO: Add backend kwargs
method = get_plotting_method("plot_autocorr", "autocorrplot", backend)
axes = method(**autocorr_plot_args)

return axes
1 change: 0 additions & 1 deletion arviz/plots/backends/__init__.py
@@ -1,2 +1 @@
"""ArviZ plotting backends."""
from .bokeh import *
27 changes: 26 additions & 1 deletion arviz/plots/backends/bokeh/__init__.py
@@ -1,7 +1,32 @@
# pylint: disable=no-member,invalid-name,redefined-outer-name
# pylint: disable=no-member,invalid-name,redefined-outer-name, wrong-import-position
"""Bokeh Plotting Backend."""
import packaging

# Set plot generic bokeh keyword arg defaults if none provided
BACKEND_KWARG_DEFAULTS = {"show": True}

from .autocorrplot import plot_autocorr
from .compareplot import plot_compare
from .densityplot import plot_density
from .distplot import plot_dist
from .elpdplot import plot_elpd
from .energyplot import plot_energy
from .essplot import plot_ess
from .forestplot import plot_forest
from .hpdplot import plot_hpd
from .jointplot import plot_joint
from .kdeplot import plot_kde
from .khatplot import plot_khat
from .loopitplot import plot_loo_pit
from .mcseplot import plot_mcse
from .pairplot import plot_pair
from .parallelplot import plot_parallel
from .ppcplot import plot_ppc
from .posteriorplot import plot_posterior
from .rankplot import plot_rank
from .traceplot import plot_trace
from .violinplot import plot_violin


def output_notebook(*args, **kwargs):
"""Wrap bokeh.plotting.output_notebook."""
Expand Down
@@ -1,16 +1,17 @@
"""Bokeh Autocorrplot."""
import numpy as np
import bokeh.plotting as bkp
from bokeh.models.annotations import Title
import numpy as np
from bokeh.layouts import gridplot
from bokeh.models.annotations import Title

from ....stats import autocorr
from ...plot_utils import make_label
from ....stats import autocorr


def _plot_autocorr(
def plot_autocorr(
axes, plotters, max_lag, line_width, combined=False, show=True,
):
"""Bokeh autocorrelation plot."""
for (var_name, selection, x), ax_ in zip(plotters, axes.flatten()):
x_prime = x
if combined:
Expand Down
Expand Up @@ -5,7 +5,7 @@
from ....rcparams import rcParams


def _compareplot(
def plot_compare(
ax,
comp_df,
figsize,
Expand All @@ -20,7 +20,7 @@ def _compareplot(
step,
show,
):

"""Bokeh compareplot."""
if ax is None:
tools = rcParams["plot.bokeh.tools"]
output_backend = rcParams["plot.bokeh.output_backend"]
Expand Down
@@ -1,16 +1,16 @@
"""Bokeh Densityplot."""
import bokeh.plotting as bkp
from bokeh.models.annotations import Title
from bokeh.layouts import gridplot
import numpy as np
from bokeh.layouts import gridplot
from bokeh.models.annotations import Title

from ....stats import hpd
from ...kdeplot import _fast_kde
from ...plot_utils import make_label
from ....stats import hpd
from ....stats.stats_utils import histogram


def _plot_density(
def plot_density(
ax,
all_labels,
to_plot,
Expand All @@ -26,6 +26,7 @@ def _plot_density(
data_labels,
show,
):
"""Bokeh density plot."""
axis_map = {label: ax_ for label, ax_ in zip(all_labels, ax.flatten())}
if data_labels is None:
data_labels = {}
Expand Down
Expand Up @@ -2,12 +2,13 @@
import bokeh.plotting as bkp
import numpy as np

from . import BACKEND_KWARG_DEFAULTS
from ...kdeplot import plot_kde
from ...plot_utils import get_bins
from ....rcparams import rcParams


def _plot_dist_bokeh(
def plot_dist(
values,
values2=None,
color="C0",
Expand All @@ -28,8 +29,14 @@ def _plot_dist_bokeh(
pcolormesh_kwargs=None,
hist_kwargs=None,
ax=None,
show=True,
backend_kwargs=None,
**kwargs # pylint: disable=unused-argument
):
"""Bokeh distplot."""
if backend_kwargs is None:
backend_kwargs = {}

backend_kwargs = {**BACKEND_KWARG_DEFAULTS, **backend_kwargs}

if ax is None:
tools = rcParams["plot.bokeh.tools"]
Expand Down Expand Up @@ -75,12 +82,14 @@ def _plot_dist_bokeh(
pcolormesh_kwargs=pcolormesh_kwargs,
ax=ax,
backend="bokeh",
# TODO: Revisit this when I refactor backend args for kde
show=False,
)
else:
raise TypeError('Invalid "kind":{}. Select from {{"auto","kde","hist"}}'.format(kind))

if show:
# TODO: Temporary setting just to make sure tests work. This needs to be removed
if backend_kwargs["show"] is True:
bkp.show(ax, toolbar_location="above")
return ax

Expand Down
Expand Up @@ -2,16 +2,15 @@
import warnings

import bokeh.plotting as bkp
from bokeh.models.annotations import Title
from bokeh.layouts import gridplot
import numpy as np

from bokeh.layouts import gridplot
from bokeh.models.annotations import Title

from ...plot_utils import _scale_fig_size
from ....rcparams import rcParams


def _plot_elpd(
def plot_elpd(
ax,
models,
pointwise_data,
Expand All @@ -26,6 +25,7 @@ def _plot_elpd(
threshold,
show,
):
"""Bokeh elpd plot."""
if numvars == 2:
(figsize, _, _, _, _, markersize) = _scale_fig_size(
figsize, textsize, numvars - 1, numvars - 1
Expand Down
Expand Up @@ -2,15 +2,16 @@
import bokeh.plotting as bkp
from bokeh.models import Label

from .distplot import _histplot_bokeh_op
from ...kdeplot import plot_kde
from .bokeh_distplot import _histplot_bokeh_op
from ....rcparams import rcParams
from ....stats import bfmi as e_bfmi


def _plot_energy(
def plot_energy(
ax, series, energy, kind, bfmi, figsize, line_width, fill_kwargs, plot_kwargs, bw, legend, show,
):
"""Bokeh energy plot."""
if ax is None:
tools = rcParams["plot.bokeh.tools"]
output_backend = rcParams["plot.bokeh.output_backend"]
Expand Down
@@ -1,23 +1,19 @@
# pylint: disable=all
"""Bokeh ESS plots."""
import bokeh.plotting as bkp
import numpy as np
from bokeh.layouts import gridplot
from bokeh.models import Dash, Span, ColumnDataSource
from bokeh.models.annotations import Title
from bokeh.layouts import gridplot
import numpy as np
from scipy.stats import rankdata


from ...plot_utils import (
make_label,
_create_axes_grid,
get_coords,
filter_plotters_list,
)
from ....rcparams import rcParams


def _plot_ess(
def plot_ess(
ax,
plotters,
xdata,
Expand Down Expand Up @@ -51,6 +47,7 @@ def _plot_ess(
hline_kwargs,
show,
):
"""Bokeh essplot."""
if ax is None:
_, ax = _create_axes_grid(
len(plotters),
Expand Down
Expand Up @@ -3,16 +3,16 @@
from collections import defaultdict, OrderedDict
from itertools import cycle, tee

import numpy as np
import bokeh.plotting as bkp
import matplotlib.pyplot as plt
import numpy as np
from bokeh.layouts import gridplot
from bokeh.models import Band, ColumnDataSource
from bokeh.models.annotations import Title
from bokeh.models.tickers import FixedTicker
from bokeh.layouts import gridplot
import matplotlib.pyplot as plt

from ...plot_utils import _scale_fig_size, xarray_var_iter, make_label, get_bins
from ...kdeplot import _fast_kde
from ...plot_utils import _scale_fig_size, xarray_var_iter, make_label, get_bins
from ....rcparams import rcParams
from ....stats import hpd
from ....stats.diagnostics import _ess, _rhat
Expand All @@ -27,7 +27,7 @@ def pairwise(iterable):
return zip(first, second)


def _plot_forest(
def plot_forest(
ax,
datasets,
var_names,
Expand All @@ -51,6 +51,7 @@ def _plot_forest(
r_hat,
show,
):
"""Bokeh forest plot."""
plot_handler = PlotHandler(
datasets, var_names=var_names, model_names=model_names, combined=combined, colors=colors
)
Expand Down
Expand Up @@ -2,13 +2,14 @@
from itertools import cycle

import bokeh.plotting as bkp
from matplotlib.pyplot import rcParams as mpl_rcParams
import numpy as np
from matplotlib.pyplot import rcParams as mpl_rcParams

from ....rcparams import rcParams


def _plot_hpdplot(ax, x_data, y_data, plot_kwargs, fill_kwargs, show):
def plot_hpd(ax, x_data, y_data, plot_kwargs, fill_kwargs, show):
"""Bokeh hpd plot."""
if ax is None:
tools = rcParams["plot.bokeh.tools"]
output_backend = rcParams["plot.bokeh.output_backend"]
Expand Down
@@ -1,15 +1,15 @@
"""Bokeh jointplot."""
import bokeh.plotting as bkp
from bokeh.layouts import gridplot
import numpy as np
from bokeh.layouts import gridplot

from ...distplot import plot_dist
from ...kdeplot import plot_kde
from ...plot_utils import make_label
from ....rcparams import rcParams


def _plot_joint(
def plot_joint(
ax,
figsize,
plotters,
Expand All @@ -22,6 +22,7 @@ def _plot_joint(
marginal_kwargs,
show,
):
"""Bokeh joint plot."""
if ax is None:
tools = rcParams["plot.bokeh.tools"]
output_backend = rcParams["plot.bokeh.output_backend"]
Expand Down Expand Up @@ -92,7 +93,7 @@ def _plot_joint(
rotated=rotate,
ax=ax_,
backend="bokeh",
show=False,
backend_kwargs={"show": False},
**marginal_kwargs
)

Expand Down

0 comments on commit b9d02ea

Please sign in to comment.