mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-42944 Fix Random.sample when counts is not None (GH-24235)
This commit is contained in:
parent
314b8787e0
commit
f7b5bacd7a
3 changed files with 29 additions and 28 deletions
|
@ -479,7 +479,7 @@ class Random(_random.Random):
|
|||
raise TypeError('Counts must be integers')
|
||||
if total <= 0:
|
||||
raise ValueError('Total of counts must be greater than zero')
|
||||
selections = sample(range(total), k=k)
|
||||
selections = self.sample(range(total), k=k)
|
||||
bisect = _bisect
|
||||
return [population[bisect(cum_counts, s)] for s in selections]
|
||||
randbelow = self._randbelow
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue