[Reproducible-commits] [misc] 01/01: shuffle.sample explodes if the population is smaller than the sample size, so bound it.
Chris Lamb
chris at chris-lamb.co.uk
Fri Aug 26 00:18:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository misc.
commit 26d7cf12f7f975877e80c9db00b8b1e1cda5413d
Author: Chris Lamb <lamby at debian.org>
Date: Fri Aug 26 01:17:56 2016 +0100
shuffle.sample explodes if the population is smaller than the sample size, so bound it.
---
filter-packages | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/filter-packages b/filter-packages
index e06ad80..7b29094 100755
--- a/filter-packages
+++ b/filter-packages
@@ -39,7 +39,7 @@ def main():
parser.add_option('--filter-ftbfs', dest='filter_ftbfs', action='store_true',
help="only match ftbfs packages")
parser.add_option('--random', dest='random', type=int, metavar='N',
- help="only print N random packages")
+ help="only print (at most) N random packages")
parser.add_option('--url', dest='url', action='store_true',
help="print url as well as the package name")
@@ -91,7 +91,7 @@ def main():
results.append((x, y))
if options.random is not None:
- results = random.sample(results, options.random)
+ results = random.sample(results, min(options.random, len(results)))
for x, y in results:
print("".join((
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/misc.git
More information about the Reproducible-commits
mailing list