changeset 18047:9196638b08ce

synthrepo: do not crash if a list is empty
author Bryan O'Sullivan <bryano@fb.com>
date Mon, 10 Dec 2012 11:18:03 -0800
parents 40374059d227
children 9b7288fc7bf2
files contrib/synthrepo.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/synthrepo.py	Tue Nov 27 22:24:02 2012 +0100
+++ b/contrib/synthrepo.py	Mon Dec 10 11:18:03 2012 -0800
@@ -231,6 +231,8 @@
     fp.close()
 
     def cdf(l):
+        if not l:
+            return [], []
         vals, probs = zip(*sorted(l, key=lambda x: x[1], reverse=True))
         t = float(sum(probs, 0))
         s, cdfs = 0, []