mirror of
https://github.com/python/cpython
synced 2024-09-05 08:17:45 +00:00
Add extra tests for random.binomialvariate
(gh-112325)
This commit is contained in:
parent
89ddea4886
commit
dc0adb44d8
|
@ -1081,6 +1081,7 @@ def test_binomialvariate(self):
|
|||
B(n=1, p=-0.5) # Negative p
|
||||
with self.assertRaises(ValueError):
|
||||
B(n=1, p=1.5) # p > 1.0
|
||||
self.assertEqual(B(0, 0.5), 0) # n == 0
|
||||
self.assertEqual(B(10, 0.0), 0) # p == 0.0
|
||||
self.assertEqual(B(10, 1.0), 10) # p == 1.0
|
||||
self.assertTrue(B(1, 0.3) in {0, 1}) # n == 1 fast path
|
||||
|
@ -1088,6 +1089,9 @@ def test_binomialvariate(self):
|
|||
self.assertTrue(B(1, 0.0) in {0}) # n == 1 fast path
|
||||
self.assertTrue(B(1, 1.0) in {1}) # n == 1 fast path
|
||||
|
||||
# BG method very small p
|
||||
self.assertEqual(B(5, 1e-18), 0)
|
||||
|
||||
# BG method p <= 0.5 and n*p=1.25
|
||||
self.assertTrue(B(5, 0.25) in set(range(6)))
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Add extra tests for :func:`random.binomialvariate`
|
Loading…
Reference in a new issue