From 783b8bef8c6fb21f6c8bd577f486812d42345aba Mon Sep 17 00:00:00 2001 From: mantaohuang Date: Tue, 28 Jul 2020 19:19:16 -0400 Subject: [PATCH] bug fix: numpy mean nan warning --- o_manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/o_manager.py b/o_manager.py index 9caef7d..9fb6b97 100644 --- a/o_manager.py +++ b/o_manager.py @@ -120,6 +120,12 @@ class OManager: value = float(value) ping_tas.add(time, value) + def io_mean(x): + if len(x): + return numpy.mean(x) + else: + return numpy.nan + def ping_mean(x): x = numpy.array(x) x = x[x > 0] @@ -274,6 +280,10 @@ class OManager: # n_down = 2 weights = [] for i in self.instances: + if i["op"].status != RUNNING: + i["weight"] = 0 + weights.append(i["weight"]) + continue n_up = i["op"].n_up n_down = i["op"].n_down ping_stat = i["op"].get_ping_stat(lines=max(n_up, n_down))