diff options
| author | Mac Mollison <mollison@cs.unc.edu> | 2010-02-11 22:04:59 -0500 |
|---|---|---|
| committer | Mac Mollison <mollison@cs.unc.edu> | 2010-02-11 22:04:59 -0500 |
| commit | 75dedea2014c9ea703bb4000fbfda45c20b196e5 (patch) | |
| tree | 1b9298a0fc32f411053f5fbea45777a1b5d2d56b | |
| parent | c2597a1111f343fe734eedd7eb6b1f784c9575cb (diff) | |
Bugfix: possible divide by zero in stats.py
| -rw-r--r-- | stats.py | 5 |
1 files changed, 4 insertions, 1 deletions
| @@ -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" |
