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

UserWarning if doing predictive sampling with models containing Potentials #4419

Merged
merged 4 commits into from
Jan 16, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Avoid sampling in unittests
  • Loading branch information
ricardoV94 committed Jan 16, 2021
commit 51db510f1f3a98462e72f6942b9263dadc99d5b3
18 changes: 9 additions & 9 deletions pymc3/tests/test_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,16 +726,15 @@ def test_potentials_warning(self):
warning_msg = "The effect of Potentials on other parameters is ignored during"
with pm.Model() as m:
a = pm.Normal("a", 0, 1)
p = pm.Potential("p", a)
p = pm.Potential("p", a + 1)
obs = pm.Normal("obs", a, 1, observed=5)
trace = pm.sample()

with pytest.warns(UserWarning, match=warning_msg):
with m:
trace = az.from_dict({"a": np.random.rand(10)})
with m:
with pytest.warns(UserWarning, match=warning_msg):
pm.sample_posterior_predictive(trace, samples=5)

with pytest.warns(UserWarning, match=warning_msg):
with m:
with pytest.warns(UserWarning, match=warning_msg):
pm.fast_sample_posterior_predictive(trace, samples=5)


Expand Down Expand Up @@ -793,10 +792,10 @@ def test_potentials_warning(self):
warning_msg = "The effect of Potentials on other parameters is ignored during"
with pm.Model() as m:
a = pm.Normal("a", 0, 1)
p = pm.Potential("p", a)
p = pm.Potential("p", a + 1)
obs = pm.Normal("obs", a, 1, observed=5)
trace = pm.sample()

trace = az.from_dict({"a": np.random.rand(10)})
with pytest.warns(UserWarning, match=warning_msg):
pm.sample_posterior_predictive_w(samples=5, traces=[trace, trace], models=[m, m])

Expand Down Expand Up @@ -1043,8 +1042,9 @@ def test_potentials_warning(self):
warning_msg = "The effect of Potentials on other parameters is ignored during"
with pm.Model() as m:
a = pm.Normal("a", 0, 1)
p = pm.Potential("p", a)
p = pm.Potential("p", a + 1)

with m:
with pytest.warns(UserWarning, match=warning_msg):
pm.sample_prior_predictive(samples=5)

Expand Down