From 3adf6927f9a207890507eb5b3a8ff0f28316944b Mon Sep 17 00:00:00 2001 From: earthgecko Date: Mon, 8 Jan 2018 14:15:50 +0000 Subject: [PATCH 1/2] fix normalize References - incorrect normalize method #40 --- src/luminol/modules/time_series.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/luminol/modules/time_series.py b/src/luminol/modules/time_series.py index d7a75e9..a351301 100644 --- a/src/luminol/modules/time_series.py +++ b/src/luminol/modules/time_series.py @@ -282,13 +282,14 @@ def add_offset(self, offset): def normalize(self): """ - Return a new time series with all values normalized to 0 to 1. + Return a new time series with all values normalized between 0 and 1. :return: `None` """ maximum = self.max() if maximum: - self.values = [value / maximum for value in self.values] + minimum = self.min() + self.values = [((value - minimum) / (maximum - minimum)) for value in self.values] def crop(self, start_timestamp, end_timestamp): """ From 24f3905558489dcf6283bd3c32f238371a108a85 Mon Sep 17 00:00:00 2001 From: earthgecko Date: Mon, 8 Jan 2018 19:46:13 +0000 Subject: [PATCH 2/2] handle no minimal Handle no minimal as no maximum is handled --- src/luminol/modules/time_series.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/luminol/modules/time_series.py b/src/luminol/modules/time_series.py index a351301..f3ba20a 100644 --- a/src/luminol/modules/time_series.py +++ b/src/luminol/modules/time_series.py @@ -289,7 +289,8 @@ def normalize(self): maximum = self.max() if maximum: minimum = self.min() - self.values = [((value - minimum) / (maximum - minimum)) for value in self.values] + if minimum: + self.values = [((value - minimum) / (maximum - minimum)) for value in self.values] def crop(self, start_timestamp, end_timestamp): """