Skip to content

Commit 3785931

Browse files
MarcoGorellimichaelosthege
authored andcommitted
fixup stacklevel
1 parent 2e7d042 commit 3785931

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pymc3/sampling.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ def sample(
480480
" complications in your downstream analysis. Please consider to switch to `InferenceData`:\n"
481481
"`pm.sample(..., return_inferencedata=True)`",
482482
UserWarning,
483+
stacklevel=2,
483484
)
484485

485486
if return_inferencedata is None:
@@ -614,6 +615,7 @@ def sample(
614615
"DEMetropolis should be used with more chains than dimensions! "
615616
"(The model has {} dimensions.)".format(initial_point_model_size),
616617
UserWarning,
618+
stacklevel=2,
617619
)
618620
_print_step_hierarchy(step)
619621
trace = _sample_population(parallelize=cores > 1, **sample_args)
@@ -666,7 +668,9 @@ def sample(
666668

667669
if compute_convergence_checks:
668670
if draws - tune < 100:
669-
warnings.warn("The number of samples is too small to check convergence reliably.")
671+
warnings.warn(
672+
"The number of samples is too small to check convergence reliably.", stacklevel=2
673+
)
670674
else:
671675
trace.report._run_convergence_checks(idata, model)
672676
trace.report._log_summary()
@@ -1664,7 +1668,8 @@ def sample_posterior_predictive(
16641668
warnings.warn(
16651669
"samples parameter is smaller than nchains times ndraws, some draws "
16661670
"and/or chains may not be represented in the returned posterior "
1667-
"predictive sample"
1671+
"predictive sample",
1672+
stacklevel=2,
16681673
)
16691674

16701675
model = modelcontext(model)
@@ -1674,6 +1679,7 @@ def sample_posterior_predictive(
16741679
"The effect of Potentials on other parameters is ignored during posterior predictive sampling. "
16751680
"This is likely to lead to invalid or biased predictive samples.",
16761681
UserWarning,
1682+
stacklevel=2,
16771683
)
16781684

16791685
if var_names is not None:
@@ -1829,6 +1835,7 @@ def sample_posterior_predictive_w(
18291835
"The effect of Potentials on other parameters is ignored during posterior predictive sampling. "
18301836
"This is likely to lead to invalid or biased predictive samples.",
18311837
UserWarning,
1838+
stacklevel=2,
18321839
)
18331840
break
18341841

@@ -1952,6 +1959,7 @@ def sample_prior_predictive(
19521959
"The effect of Potentials on other parameters is ignored during prior predictive sampling. "
19531960
"This is likely to lead to invalid or biased predictive samples.",
19541961
UserWarning,
1962+
stacklevel=2,
19551963
)
19561964

19571965
if var_names is None:

0 commit comments

Comments
 (0)