Skip to content

Commit ce89404

Browse files
mattiadgricardoV94
andauthored
Fix flaky TestTruncation.truncation_discrete_random (#6229)
Co-authored-by: Ricardo Vieira <[email protected]>
1 parent 652c9de commit ce89404

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pymc/tests/distributions/test_truncated.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ def test_truncation_discrete_random(op_type, lower, upper):
181181
assert np.any(xt_draws == upper)
182182
else:
183183
with pytest.raises(TruncationError, match="^Truncation did not converge"):
184-
draw(xt)
184+
# Rejections sampling with probability = (1 - p ** max_n_steps) ** sample_size =
185+
# = (1 - 0.2 ** 3) ** 500 = 0.018
186+
# Still, this probability can be too high to make this test pass with any seed.
187+
draw(xt, random_seed=2297228)
185188

186189

187190
@pytest.mark.parametrize("lower, upper", [(2, np.inf), (2, 5), (-np.inf, 5)])

0 commit comments

Comments
 (0)