Merge pull request #2181 from fjarri/fixed-rng-in-sampling-test

Fix RNG seed in the sampling test to avoid low-probability random fails
pull/2183/head
David Núñez 2020-08-18 12:21:03 +02:00 committed by GitHub
commit b1b3c933bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -157,7 +157,10 @@ def probability_reference_no_replacement(weights, idxs):
def test_weighted_sampler(sample_size):
weights = [1, 9, 100, 2, 18, 70]
elements = list(range(len(weights)))
rng = random.SystemRandom()
# Use a fixed seed to avoid flakyness of the test
rng = random.Random(123)
counter = Counter()
weighted_elements = {element: weight for element, weight in zip(elements, weights)}