mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-38881: choices() raises ValueError when all weights are zero (GH-17362)
This commit is contained in:
parent
84b1ff6560
commit
041d8b48a2
4 changed files with 15 additions and 3 deletions
|
@ -241,6 +241,11 @@ class TestBasicOps:
|
|||
choices = self.gen.choices
|
||||
choices(population=[1, 2], weights=[1e-323, 1e-323], k=5000)
|
||||
|
||||
def test_choices_with_all_zero_weights(self):
|
||||
# See issue #38881
|
||||
with self.assertRaises(ValueError):
|
||||
self.gen.choices('AB', [0.0, 0.0])
|
||||
|
||||
def test_gauss(self):
|
||||
# Ensure that the seed() method initializes all the hidden state. In
|
||||
# particular, through 2.2.1 it failed to reset a piece of state used
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue