Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoV94 committed May 15, 2021
1 parent beae49c commit 588c8c4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pymc3/tests/test_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,3 +1105,18 @@ def test_sample_deterministic():
trace = pm.sample(chains=1, draws=50, compute_convergence_checks=False)

np.testing.assert_allclose(trace["y"], trace["x"] + 100)


def test_unused_assigned_step():
with pm.Model() as model:
x = pm.Bernoulli("x", 0.5)

with pytest.raises(ValueError) as err:
with model:
step = pm.BinaryMetropolis([model["x"]])
pm.sample(tune=1, draws=1, step=step)
assert str(err.value).startswith("The following variables were assigned to a step but")

with model:
step = pm.BinaryMetropolis([model.rvs_to_values[model["x"]]])
pm.sample(tune=1, draws=1, step=step)

0 comments on commit 588c8c4

Please sign in to comment.