diff --git a/pymc3/tests/test_sampling.py b/pymc3/tests/test_sampling.py index 84565f6219c..71bac2413d6 100644 --- a/pymc3/tests/test_sampling.py +++ b/pymc3/tests/test_sampling.py @@ -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)