summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMac Mollison <mollison@cs.unc.edu>2010-02-11 22:04:59 -0500
committerMac Mollison <mollison@cs.unc.edu>2010-02-11 22:04:59 -0500
commit75dedea2014c9ea703bb4000fbfda45c20b196e5 (patch)
tree1b9298a0fc32f411053f5fbea45777a1b5d2d56b
parentc2597a1111f343fe734eedd7eb6b1f784c9575cb (diff)
Bugfix: possible divide by zero in stats.py
-rw-r--r--stats.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/stats.py b/stats.py
index 6216f44..d61be6f 100644
--- a/stats.py
+++ b/stats.py
@@ -24,7 +24,10 @@ def stats(stream):
24 min_inversion = length 24 min_inversion = length
25 sum_inversions += length 25 sum_inversions += length
26 yield record 26 yield record
27 avg_inversion = int(sum_inversions / num_inversions) 27 if num_inversions > 0:
28 avg_inversion = int(sum_inversions / num_inversions)
29 else:
30 avg_inversion = 0
28 class Obj(): pass 31 class Obj(): pass
29 rec = Obj() 32 rec = Obj()
30 rec.record_type = "meta" 33 rec.record_type = "meta"