When the results are too small to calculate
the slope, an exception is reported in the
logs. This change avoids triggering the
exception criteria.
Change-Id: Iae886cde6244e9077ff94812bd830c48adaef365
Signed-off-by: mbeierl <mark.beierl@dell.com>
avg = average(average_series)
slp = slope(data_series)
+ if slp is None or avg is None:
+ return new_series
+
multiplier = float(len(data_series) + 1) / 2.0 - len(data_series)
for index, _ in data_series:
new_value = avg + (slp * multiplier)
actual = Slope.slope([])
self.assertEqual(expected, actual)
+ def test_slope_one_series(self):
+ expected = None
+ actual = Slope.slope([[1, 0.0]])
+ self.assertEqual(expected, actual)
+
def test_slope_integer_series(self):
expected = 1.4
actual = Slope.slope([[1, 6], [2, 5], [3, 7], [4, 10]])