Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert all instances of SyntaxWarning to UserWarning #1016

Merged
merged 1 commit into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arviz/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def generate_dims_coords(shape, var_name, dims=None, coords=None, default_dims=N
shape_len=len(shape),
defaults=",".join(default_dims) + ", " if default_dims is not None else "",
),
SyntaxWarning,
UserWarning,
)
if coords is None:
coords = {}
Expand Down Expand Up @@ -142,7 +142,7 @@ def numpy_to_data_array(ary, *, var_name="data", coords=None, dims=None):
"Passed array should have shape (chains, draws, *shape)".format(
n_chains=n_chains, n_samples=n_samples
),
SyntaxWarning,
UserWarning,
)

dims, coords = generate_dims_coords(
Expand Down
2 changes: 1 addition & 1 deletion arviz/data/io_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def posterior_to_xarray(self):
warnings.warn(
"log_likelihood found in posterior."
" For stats functions log_likelihood needs to be in sample_stats.",
SyntaxWarning,
UserWarning,
)

return dict_to_dataset(data, library=None, coords=self.coords, dims=self.dims)
Expand Down
4 changes: 2 additions & 2 deletions arviz/data/io_emcee.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ def _verify_names(sampler, var_names, arg_names, slices):
warnings.warn(
"Check slices: Not all parameters in chain captured. "
"{} are present, and {} have been captured.".format(ndim, len(slicing_try)),
SyntaxWarning,
UserWarning,
)
if len(slicing_try) != len(set(slicing_try)):
warnings.warn(
"Overlapping slices. Check the index present: {}".format(slicing_try), SyntaxWarning
"Overlapping slices. Check the index present: {}".format(slicing_try), UserWarning
)

if var_names is None:
Expand Down
2 changes: 1 addition & 1 deletion arviz/plots/backends/bokeh/elpdplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def plot_elpd(
"rcParams['plot.max_subplots'] ({max_plots}) is smaller than the number "
"of resulting ELPD pairwise plots with these variables, generating only a "
"{side}x{side} grid".format(max_plots=max_plots, side=vars_to_plot),
SyntaxWarning,
UserWarning,
)
numvars = vars_to_plot

Expand Down
2 changes: 1 addition & 1 deletion arviz/plots/backends/bokeh/pairplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def plot_pair(
"rcParams['plot.max_subplots'] ({max_plots}) is smaller than the number "
"of resulting pair plots with these variables, generating only a "
"{side}x{side} grid".format(max_plots=max_plots, side=vars_to_plot),
SyntaxWarning,
UserWarning,
)
numvars = vars_to_plot

Expand Down
2 changes: 1 addition & 1 deletion arviz/plots/backends/matplotlib/elpdplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def plot_elpd(
"rcParams['plot.max_subplots'] ({max_plots}) is smaller than the number "
"of resulting ELPD pairwise plots with these variables, generating only a "
"{side}x{side} grid".format(max_plots=max_plots, side=vars_to_plot),
SyntaxWarning,
UserWarning,
)
numvars = vars_to_plot

Expand Down
2 changes: 1 addition & 1 deletion arviz/plots/backends/matplotlib/pairplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def plot_pair(
"rcParams['plot.max_subplots'] ({max_plots}) is smaller than the number "
"of resulting pair plots with these variables, generating only a "
"{side}x{side} grid".format(max_plots=max_plots, side=vars_to_plot),
SyntaxWarning,
UserWarning,
)
numvars = vars_to_plot

Expand Down
2 changes: 1 addition & 1 deletion arviz/plots/densityplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def plot_density(
"rcParams['plot.max_subplots'] ({max_plots}) is smaller than the number "
"of variables to plot ({len_plotters}) in plot_density, generating only "
"{max_plots} plots".format(max_plots=max_plots, len_plotters=length_plotters),
SyntaxWarning,
UserWarning,
)
all_labels = all_labels[:max_plots]
to_plot = [
Expand Down
2 changes: 1 addition & 1 deletion arviz/plots/pairplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def plot_pair(
"Make sure the sample method provides divergences data and "
"that it is present in the `diverging` field of `sample_stats` "
"or `sample_stats_prior` or set divergences=False",
SyntaxWarning,
UserWarning,
)

if gridsize == "auto":
Expand Down
2 changes: 1 addition & 1 deletion arviz/plots/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def filter_plotters_list(plotters, plot_kind):
"{max_plots} plots".format(
max_plots=max_plots, len_plotters=len(plotters), plot_kind=plot_kind
),
SyntaxWarning,
UserWarning,
)
return plotters[:max_plots]
return plotters
Expand Down
2 changes: 1 addition & 1 deletion arviz/plots/traceplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def plot_trace(
"rcParams['plot.max_subplots'] ({max_plots}) is smaller than the number "
"of variables to plot ({len_plotters}), generating only {max_plots} "
"plots".format(max_plots=max_plots, len_plotters=len(plotters)),
SyntaxWarning,
UserWarning,
)
plotters = plotters[:max_plots]

Expand Down
8 changes: 4 additions & 4 deletions arviz/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_dims_coords():
def test_dims_coords_extra_dims():
shape = 4, 20
var_name = "x"
with pytest.warns(SyntaxWarning):
with pytest.warns(UserWarning):
dims, coords = generate_dims_coords(shape, var_name, dims=["xx", "xy", "xz"])
assert "xx" in dims
assert "xy" in dims
Expand Down Expand Up @@ -419,7 +419,7 @@ def test_1d_dataset(self):

def test_warns_bad_shape(self):
# Shape should be (chain, draw, *shape)
with pytest.warns(SyntaxWarning):
with pytest.warns(UserWarning):
convert_to_dataset(np.random.randn(100, 4))

def test_nd_to_dataset(self):
Expand Down Expand Up @@ -448,7 +448,7 @@ def test_nd_to_inference_data(self):

def test_more_chains_than_draws(self):
shape = (10, 4)
with pytest.warns(SyntaxWarning):
with pytest.warns(UserWarning):
inference_data = convert_to_inference_data(np.random.randn(*shape), group="foo")
assert hasattr(inference_data, "foo")
assert len(inference_data.foo.data_vars) == 1
Expand Down Expand Up @@ -688,7 +688,7 @@ def test_inference_data_bad(self):

def test_from_dict_warning(self):
bad_posterior_dict = {"log_likelihood": np.ones((5, 1000, 2))}
with pytest.warns(SyntaxWarning):
with pytest.warns(UserWarning):
from_dict(posterior=bad_posterior_dict)


Expand Down
2 changes: 1 addition & 1 deletion arviz/tests/test_data_emcee.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_verify_arg_names(self, data):

@pytest.mark.parametrize("slices", [[0, 0, slice(2, None)], [0, 1, slice(1, None)]])
def test_slices_warning(self, data, slices):
with pytest.warns(SyntaxWarning):
with pytest.warns(UserWarning):
from_emcee(data.obj, slices=slices)

def test_no_blobs_error(self):
Expand Down
2 changes: 1 addition & 1 deletion arviz/tests/test_plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_filter_plotter_list():
def test_filter_plotter_list_warning():
plotters = list(range(7))
with rc_context({"plot.max_subplots": 5}):
with pytest.warns(SyntaxWarning, match="test warning"):
with pytest.warns(UserWarning, match="test warning"):
plotters_filtered = filter_plotters_list(plotters, "test warning")
assert len(plotters_filtered) == 5

Expand Down
4 changes: 2 additions & 2 deletions arviz/tests/test_plots_bokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_plot_trace_discrete(discrete_model):


def test_plot_trace_max_subplots_warning(models):
with pytest.warns(SyntaxWarning):
with pytest.warns(UserWarning):
with rc_context(rc={"plot.max_subplots": 1}):
axes = plot_trace(models.model_1, backend="bokeh", show=False)
assert axes.shape
Expand Down Expand Up @@ -724,7 +724,7 @@ def test_plot_pair_divergences_warning(has_sample_stats):
else:
# sample_stats missing
data = data.posterior # pylint: disable=no-member
with pytest.warns(SyntaxWarning):
with pytest.warns(UserWarning):
ax = plot_pair(data, divergences=True, backend="bokeh", show=False)
assert np.any(ax)

Expand Down
4 changes: 2 additions & 2 deletions arviz/tests/test_plots_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_plot_trace_discrete(discrete_model):


def test_plot_trace_max_subplots_warning(models):
with pytest.warns(SyntaxWarning):
with pytest.warns(UserWarning):
with rc_context(rc={"plot.max_subplots": 1}):
axes = plot_trace(models.model_1)
assert axes.shape
Expand Down Expand Up @@ -400,7 +400,7 @@ def test_plot_pair_divergences_warning(has_sample_stats):
else:
# sample_stats missing
data = data.posterior # pylint: disable=no-member
with pytest.warns(SyntaxWarning):
with pytest.warns(UserWarning):
ax = plot_pair(data, divergences=True)
assert np.all(ax)

Expand Down