Browse Source

Error: '<' not supported between instances of 'NoneType' and 'NoneType' #323 (#332)

pull/1/head
Alexandr Velikiy 6 years ago committed by rozetko
parent
commit
b1428c735f
  1. 3
      analytics/analytics/analytic_unit_manager.py
  2. 15
      analytics/tests/test_dataset.py

3
analytics/analytics/analytic_unit_manager.py

@ -31,9 +31,8 @@ def prepare_data(data: list):
- subtracts min value from dataset
"""
data = pd.DataFrame(data, columns=['timestamp', 'value'])
data['timestamp'] = pd.to_datetime(data['timestamp'], unit='ms')
if not np.isnan(min(data['value'])):
if not np.isnan(data['value'].min()):
data['value'] = data['value'] - min(data['value'])
return data

15
analytics/tests/test_dataset.py

@ -1,5 +1,6 @@
import unittest
import pandas as pd
import numpy as np
from analytic_unit_manager import prepare_data
import models
@ -100,6 +101,20 @@ class TestDataset(unittest.TestCase):
model.fit(dataframe, segments, dict())
except ValueError:
self.fail('Model {} raised unexpectedly'.format(model_name))
def test_prepare_data_for_nonetype(self):
data = [[1523889000000, None], [1523889000001, None], [1523889000002, None]]
try:
data = prepare_data(data)
except ValueError:
self.fail('Model {} raised unexpectedly'.format(model_name))
def test_prepare_data_for_nan(self):
data = [[1523889000000, np.NaN], [1523889000001, np.NaN], [1523889000002, np.NaN]]
try:
data = prepare_data(data)
except ValueError:
self.fail('Model {} raised unexpectedly'.format(model_name))
if __name__ == '__main__':
unittest.main()

Loading…
Cancel
Save