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) (GH-24243)
This commit is contained in:
parent
799722cb0d
commit
a90539f572
3 changed files with 29 additions and 28 deletions
|
@ -442,7 +442,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