From d17cb3fafc91fa81e00afcc416df227ab67cc467 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Fri, 19 Jan 2018 02:21:54 +0100 Subject: [PATCH] Helper for avg calculation --- src/util/helper.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/helper.py b/src/util/helper.py index 0da5bddd..3a6aa446 100644 --- a/src/util/helper.py +++ b/src/util/helper.py @@ -211,3 +211,9 @@ def limitedGzipFile(*args, **kwargs): def read(self, size=-1): return super(LimitedGzipFile, self).read(1024*1024*6) return LimitedGzipFile(*args, **kwargs) + +def avg(items): + if len(items) > 0: + return sum(items) / len(items) + else: + return 0 \ No newline at end of file