From: shreddd Date: Wed, 3 Jul 2013 09:21:19 +0000 (+1200) Subject: fix mean_sightings X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8ee914a867a8df6f57b34a1f9720eaaf55084841;p=swc-testing-nose.git fix mean_sightings --- diff --git a/python/mean_sightings-full.py b/python/mean_sightings-full.py index a76c416..55c5148 100755 --- a/python/mean_sightings-full.py +++ b/python/mean_sightings-full.py @@ -40,14 +40,17 @@ def get_sightings_loop(filename, focusanimal): focusanimal = focusanimal.capitalize() # Loop through all records, countings recs and animals - totalrecs = 0 - totalcount = 0 + totalrecs = 0. + totalcount = 0. for rec in tab: if rec['animal'] == focusanimal: totalrecs += 1 totalcount += rec['count'] - meancount = totalcount/totalrecs + if totalrecs==0: + meancount = 0 + else: + meancount = totalcount/totalrecs # Return num of records and animals seen return totalrecs, meancount