fix shuffle
This commit is contained in:
parent
f1da3c55cd
commit
0cc1b6c4a4
|
@ -326,8 +326,8 @@ def shuffle(values: List[Any],
|
||||||
|
|
||||||
# entropy is consumed in 3 byte chunks
|
# entropy is consumed in 3 byte chunks
|
||||||
# rand_max is defined to remove the modulo bias from this entropy source
|
# rand_max is defined to remove the modulo bias from this entropy source
|
||||||
SAMPLE_RANGE = 2 ** 24
|
rand_max = 2 ** 24
|
||||||
assert values_count <= SAMPLE_RANGE:
|
assert values_count <= rand_max:
|
||||||
|
|
||||||
output = [x for x in values]
|
output = [x for x in values]
|
||||||
source = seed
|
source = seed
|
||||||
|
@ -344,7 +344,7 @@ def shuffle(values: List[Any],
|
||||||
break
|
break
|
||||||
|
|
||||||
# Set a random maximum bound of sample_from_source
|
# Set a random maximum bound of sample_from_source
|
||||||
rand_max = SAMPLE_RANGE - SAMPLE_RANGE % remaining
|
rand_max = rand_max - rand_max % remaining
|
||||||
|
|
||||||
# Select `replacement_position` with the given `sample_from_source` and `remaining`
|
# Select `replacement_position` with the given `sample_from_source` and `remaining`
|
||||||
if sample_from_source < rand_max:
|
if sample_from_source < rand_max:
|
||||||
|
|
Loading…
Reference in New Issue