Skip to content

Commit

Permalink
homogenize mpl and bokeh versions
Browse files Browse the repository at this point in the history
  • Loading branch information
OriolAbril committed Dec 20, 2024
1 parent 69f9fb9 commit c9d28ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions arviz/plots/backends/bokeh/bpvplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def plot_bpv(
plot_ref_kwargs,
backend_kwargs,
show,
smoothing,
):
"""Bokeh bpv plot."""
if backend_kwargs is None:
Expand Down Expand Up @@ -90,6 +91,9 @@ def plot_bpv(
obs_vals = obs_vals.flatten()
pp_vals = pp_vals.reshape(total_pp_samples, -1)

if (obs_vals.dtype.kind == "i" or pp_vals.dtype.kind == "i") and smoothing == True:
obs_vals, pp_vals = smooth_data(obs_vals, pp_vals)

if kind == "p_value":
tstat_pit = np.mean(pp_vals <= obs_vals, axis=-1)
x_s, tstat_pit_dens = kde(tstat_pit)
Expand All @@ -115,9 +119,6 @@ def plot_bpv(
)

elif kind == "u_value":
if obs_vals.dtype.kind == "i" or pp_vals.dtype.kind == "i":
obs_vals, pp_vals = smooth_data(obs_vals, pp_vals)

tstat_pit = np.mean(pp_vals <= obs_vals, axis=0)
x_s, tstat_pit_dens = kde(tstat_pit)
ax_i.line(x_s, tstat_pit_dens, color=color)
Expand Down
10 changes: 7 additions & 3 deletions arviz/plots/bpvplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def plot_bpv(
bpv=True,
plot_mean=True,
reference="analytical",
smoothing=None,
mse=False,
n_ref=100,
hdi_prob=0.94,
Expand All @@ -36,7 +37,6 @@ def plot_bpv(
backend_kwargs=None,
group="posterior",
show=None,
smoothing=True,
):
r"""Plot Bayesian p-value for observed data and Posterior/Prior predictive.
Expand Down Expand Up @@ -73,6 +73,9 @@ def plot_bpv(
reference : {"analytical", "samples", None}, default "analytical"
How to compute the distributions used as reference for ``kind=u_values``
or ``kind=p_values``. Use `None` to not plot any reference.
smoothing : bool, optional
If True and the data has integer dtype, smooth the data before computing the p-values,
u-values or tstat. By default, True when `kind` is "u_value" and False otherwise.
mse : bool, default False
Show scaled mean square error between uniform distribution and marginal p_value
distribution.
Expand Down Expand Up @@ -149,8 +152,6 @@ def plot_bpv(
the same comparison happens, but with the values in `prior_predictive` group.
show : bool, optional
Call backend show function.
smoothing : bool, default True
If True, smooth the data before computing the p-values or u-values.
Returns
-------
Expand Down Expand Up @@ -209,6 +210,9 @@ def plot_bpv(
elif not 1 >= hdi_prob > 0:
raise ValueError("The value of hdi_prob should be in the interval (0, 1]")

if smoothing is None:
smoothing = kind.lower() == "u_value"

if data_pairs is None:
data_pairs = {}

Expand Down

0 comments on commit c9d28ca

Please sign in to comment.