Rename rand_max to sample_max

This commit is contained in:
Hsiao-Wei Wang 2018-10-11 02:47:40 +08:00
parent 39a5bac337
commit 31eb7e9a05
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
1 changed files with 5 additions and 5 deletions

View File

@ -325,9 +325,9 @@ def shuffle(values: List[Any],
values_count = len(values)
# entropy is consumed in 3 byte chunks
# rand_max is defined to remove the modulo bias from this entropy source
rand_max = 2 ** 24
assert values_count <= rand_max:
# sample_max is defined to remove the modulo bias from this entropy source
sample_max = 2 ** 24
assert values_count <= sample_max
output = [x for x in values]
source = seed
@ -344,10 +344,10 @@ def shuffle(values: List[Any],
break
# Set a random maximum bound of sample_from_source
rand_max = rand_max - rand_max % remaining
sample_max = sample_max - sample_max % remaining
# Select `replacement_position` with the given `sample_from_source` and `remaining`
if sample_from_source < rand_max:
if sample_from_source < sample_max:
# Use random number to get `replacement_position`, where it's not `index`
replacement_position = (sample_from_source % remaining) + index
# Swap the index-th and replacement_position-th elements