FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add extra tests for `random.binomialvariate` by gaogaotiantian · Pull Request #112325 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 4 additions & 0 deletions Lib/test/test_random.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1081,13 +1081,17 @@ 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
self.assertTrue(B(1, 0.9) in {0, 1}) # n == 1 fast path
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)))

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add extra tests for :func:`random.binomialvariate`

Back | FazBrowse Home | New Git URL