Browse Source

Increase chunks' intersection (#513)

pull/1/head
Evgeny Smyshlyaev 6 years ago committed by rozetko
parent
commit
fb04ba1565
  1. 2
      analytics/analytics/utils/dataframe.py
  2. 9
      analytics/tests/test_detector_chunks.py

2
analytics/analytics/utils/dataframe.py

@ -15,7 +15,7 @@ def get_data_chunks(dataframe: pd.DataFrame, window_size: int, chunk_size: int)
yield dataframe
return
nonintersected = chunk_size - window_size
nonintersected = chunk_size - 2 * window_size
offset = 0
while True:

9
analytics/tests/test_detector_chunks.py

@ -7,15 +7,14 @@ class TestUtils(unittest.TestCase):
def test_chunks_generator(self):
window_size = 1
chunk_window_size_factor = 3
chunk_window_size_factor = 4
cases = [
(list(range(7)), [[0,1,2], [2,3,4], [4,5,6]]),
(list(range(8)), [[0,1,2,3], [2,3,4,5], [4,5,6,7]]),
([], [[]]),
(list(range(1)), [[0]]),
(list(range(3)), [[0,1,2]]),
(list(range(8)), [[0,1,2], [2,3,4], [4,5,6], [6,7]]),
(list(range(6)), [[0,1,2], [2,3,4], [4,5]])
(list(range(4)), [[0,1,2,3]]),
(list(range(9)), [[0,1,2,3], [2,3,4,5], [4,5,6,7], [6,7,8]])
]
for data, expected_chunks in cases:

Loading…
Cancel
Save