mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #18844: Fix-up examples for random.choices(). Remove over-specified test.
This commit is contained in:
parent
95b826d050
commit
1c3a121bb0
2 changed files with 27 additions and 35 deletions
|
@ -178,8 +178,6 @@ class TestBasicOps:
|
|||
self.assertTrue(set(choices(data, weights=None, k=5)) <= set(data))
|
||||
with self.assertRaises(ValueError):
|
||||
choices(data, [1,2], k=5) # len(weights) != len(population)
|
||||
with self.assertRaises(IndexError):
|
||||
choices(data, [0]*4, k=5) # weights sum to zero
|
||||
with self.assertRaises(TypeError):
|
||||
choices(data, 10, k=5) # non-iterable weights
|
||||
with self.assertRaises(TypeError):
|
||||
|
@ -194,8 +192,6 @@ class TestBasicOps:
|
|||
|
||||
with self.assertRaises(ValueError):
|
||||
choices(data, cum_weights=[1,2], k=5) # len(weights) != len(population)
|
||||
with self.assertRaises(IndexError):
|
||||
choices(data, cum_weights=[0]*4, k=5) # cum_weights sum to zero
|
||||
with self.assertRaises(TypeError):
|
||||
choices(data, cum_weights=10, k=5) # non-iterable cum_weights
|
||||
with self.assertRaises(TypeError):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue