X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fnew%2Futils.py;h=a4e24663b50f17b1a7ed7f9947878dba1098b9e2;hb=938a0c9cec6d2177e098653ad398372fb482c36f;hp=83f4f6249b9d78fb2a9a6055ebb629d2fd01d790;hpb=beeb2acb9ac153eaa54983bea46a76d596168965;p=csit.git diff --git a/resources/tools/presentation/new/utils.py b/resources/tools/presentation/new/utils.py index 83f4f6249b..a4e24663b5 100644 --- a/resources/tools/presentation/new/utils.py +++ b/resources/tools/presentation/new/utils.py @@ -211,19 +211,21 @@ def archive_input_data(spec): def classify_anomalies(data): """Process the data and return anomalies and trending values. - Gathers data into groups with common trend value. - Decorates first value in the group to be an outlier, regression, - normal or progression. + Gather data into groups with average as trend value. + Decorate values within groups to be normal, + the first value of changed average as a regression, or a progression. :param data: Full data set with unavailable samples replaced by nan. :type data: pandas.Series :returns: Classification and trend values :rtype: 2-tuple, list of strings and list of floats """ - bare_data = [sample for _, sample in data.iteritems() - if not np.isnan(sample)] + # Nan mean something went wrong. + # Use 0.0 to cause that being reported as a severe regression. + bare_data = [0.0 if np.isnan(sample) else sample + for _, sample in data.iteritems()] # TODO: Put analogous iterator into jumpavg library. - groups = BitCountingClassifier.classify(bare_data) + groups = BitCountingClassifier().classify(bare_data) groups.reverse() # Just to use .pop() for FIFO. classification = [] avgs = [] @@ -237,7 +239,7 @@ def classify_anomalies(data): continue if values_left < 1 or active_group is None: values_left = 0 - while values_left < 1: # To ignore empty groups. + while values_left < 1: # Ignore empty groups (should not happen). active_group = groups.pop() values_left = len(active_group.values) avg = active_group.metadata.avg