Add extra tests for `random.binomialvariate` (gh-112325)

This commit is contained in:
Tian Gao 2023-11-23 10:31:03 -08:00 committed by GitHub
parent 89ddea4886
commit dc0adb44d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -1081,6 +1081,7 @@ class TestDistributions(unittest.TestCase):
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 @@ class TestDistributions(unittest.TestCase):
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)))

View File

@ -0,0 +1 @@
Add extra tests for :func:`random.binomialvariate`