diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /library/python/reservoir_sampling/__init__.py | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/python/reservoir_sampling/__init__.py')
-rw-r--r-- | library/python/reservoir_sampling/__init__.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/library/python/reservoir_sampling/__init__.py b/library/python/reservoir_sampling/__init__.py index 4ee46ee5e1..7fc579feb4 100644 --- a/library/python/reservoir_sampling/__init__.py +++ b/library/python/reservoir_sampling/__init__.py @@ -1,16 +1,16 @@ -import random - - -def reservoir_sampling(data, nsamples, prng=None): - if prng is None: - prng = random - - result = [] - for i, entry in enumerate(data): - if i < nsamples: - result.append(entry) - else: - j = prng.randint(0, i) - if j < nsamples: - result[j] = entry - return result +import random + + +def reservoir_sampling(data, nsamples, prng=None): + if prng is None: + prng = random + + result = [] + for i, entry in enumerate(data): + if i < nsamples: + result.append(entry) + else: + j = prng.randint(0, i) + if j < nsamples: + result[j] = entry + return result |