Skip to content

Commit

Permalink
Fix flaky TestTruncation.truncation_discrete_random (#6229)
Browse files Browse the repository at this point in the history
Co-authored-by: Ricardo Vieira <28983449+ricardoV94@users.noreply.github.com>
  • Loading branch information
mattiadg and ricardoV94 authored Oct 24, 2022
1 parent 652c9de commit ce89404
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pymc/tests/distributions/test_truncated.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ def test_truncation_discrete_random(op_type, lower, upper):
assert np.any(xt_draws == upper)
else:
with pytest.raises(TruncationError, match="^Truncation did not converge"):
draw(xt)
# Rejections sampling with probability = (1 - p ** max_n_steps) ** sample_size =
# = (1 - 0.2 ** 3) ** 500 = 0.018
# Still, this probability can be too high to make this test pass with any seed.
draw(xt, random_seed=2297228)


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

0 comments on commit ce89404

Please sign in to comment.