From eb3674f0d0e4663e8970604f88828e3f240bd88b Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Mon, 16 May 2011 12:13:24 -0400 Subject: [PATCH] Fix div by zero prob. --- survey/makestats | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/survey/makestats b/survey/makestats index 7b229b1..09b0c94 100755 --- a/survey/makestats +++ b/survey/makestats @@ -187,7 +187,10 @@ def mkpic_os_per_env(db, destdir): stats[os_family_rev[os]] += counts[os] total_count = np.sum(stats.values()) for osf in stats: - stats[osf] = float(stats[osf]) / total_count + if not total_count: + stats[osf] = 0 + else: + stats[osf] = float(stats[osf]) / total_count env_stats[env] = stats # make stacked barplot pl.figure(figsize=(6.4, 4.8)) -- 2.39.2