|
|
@ -287,5 +287,87 @@ class TestUtils(unittest.TestCase): |
|
|
|
result = [(3, 7)] |
|
|
|
result = [(3, 7)] |
|
|
|
self.assertEqual(utils.get_borders_of_peaks(pattern_center, data, ws, confidence, inverse = True), result) |
|
|
|
self.assertEqual(utils.get_borders_of_peaks(pattern_center, data, ws, confidence, inverse = True), result) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_start_and_end_of_segments(self): |
|
|
|
|
|
|
|
segments = [[1, 2, 3, 4], [5, 6, 7], [8], [], [12, 12]] |
|
|
|
|
|
|
|
result = [[1, 4], [5, 7], [8, 8], [12, 12]] |
|
|
|
|
|
|
|
utils_result = utils.get_start_and_end_of_segments(segments) |
|
|
|
|
|
|
|
for idx, val in enumerate(utils_result): |
|
|
|
|
|
|
|
self.assertEqual(result[idx][0], val[0]) |
|
|
|
|
|
|
|
self.assertEqual(result[idx][1], val[1]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_start_and_end_of_segments_empty(self): |
|
|
|
|
|
|
|
segments = [] |
|
|
|
|
|
|
|
result = [] |
|
|
|
|
|
|
|
utils_result = utils.get_start_and_end_of_segments(segments) |
|
|
|
|
|
|
|
self.assertEqual(result, utils_result) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_intersecting_intervals(self): |
|
|
|
|
|
|
|
index = [[10, 20], [30, 40]] |
|
|
|
|
|
|
|
result = [[10, 20], [30, 40]] |
|
|
|
|
|
|
|
utils_result = utils.merge_intersecting_intervals(index) |
|
|
|
|
|
|
|
for idx, val in enumerate(utils_result): |
|
|
|
|
|
|
|
self.assertEqual(result[idx][0], val[0]) |
|
|
|
|
|
|
|
self.assertEqual(result[idx][1], val[1]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_intersecting_intervals_1(self): |
|
|
|
|
|
|
|
index = [[10, 20], [13, 23], [15, 17], [20, 40]] |
|
|
|
|
|
|
|
result = [[10, 40]] |
|
|
|
|
|
|
|
utils_result = utils.merge_intersecting_intervals(index) |
|
|
|
|
|
|
|
for idx, val in enumerate(utils_result): |
|
|
|
|
|
|
|
self.assertEqual(result[idx][0], val[0]) |
|
|
|
|
|
|
|
self.assertEqual(result[idx][1], val[1]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_intersecting_intervals_empty(self): |
|
|
|
|
|
|
|
index = [] |
|
|
|
|
|
|
|
result = [] |
|
|
|
|
|
|
|
utils_result = utils.merge_intersecting_intervals(index) |
|
|
|
|
|
|
|
self.assertEqual(result, utils_result) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_intersecting_intervals_one(self): |
|
|
|
|
|
|
|
index = [[10, 20]] |
|
|
|
|
|
|
|
result = [[10, 20]] |
|
|
|
|
|
|
|
utils_result = utils.merge_intersecting_intervals(index) |
|
|
|
|
|
|
|
self.assertEqual(result, utils_result) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_intersecting_intervals_2(self): |
|
|
|
|
|
|
|
index = [[10, 20], [13, 23], [25, 30], [35, 40]] |
|
|
|
|
|
|
|
result = [[10, 23], [25, 30], [35, 40]] |
|
|
|
|
|
|
|
utils_result = utils.merge_intersecting_intervals(index) |
|
|
|
|
|
|
|
for idx, val in enumerate(utils_result): |
|
|
|
|
|
|
|
self.assertEqual(result[idx][0], val[0]) |
|
|
|
|
|
|
|
self.assertEqual(result[idx][1], val[1]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_intersecting_intervals_3(self): |
|
|
|
|
|
|
|
index = [[10, 50], [5, 40], [15, 25], [6, 50]] |
|
|
|
|
|
|
|
result = [[5, 50]] |
|
|
|
|
|
|
|
utils_result = utils.merge_intersecting_intervals(index) |
|
|
|
|
|
|
|
for idx, val in enumerate(utils_result): |
|
|
|
|
|
|
|
self.assertEqual(result[idx][0], val[0]) |
|
|
|
|
|
|
|
self.assertEqual(result[idx][1], val[1]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_intersecting_intervals_4(self): |
|
|
|
|
|
|
|
index = [[5, 10], [10, 20], [25, 50]] |
|
|
|
|
|
|
|
result = [[5, 20], [25, 50]] |
|
|
|
|
|
|
|
utils_result = utils.merge_intersecting_intervals(index) |
|
|
|
|
|
|
|
for idx, val in enumerate(utils_result): |
|
|
|
|
|
|
|
self.assertEqual(result[idx][0], val[0]) |
|
|
|
|
|
|
|
self.assertEqual(result[idx][1], val[1]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_intersecting_intervals_5(self): |
|
|
|
|
|
|
|
index = [[20, 40], [10, 15], [50, 60]] |
|
|
|
|
|
|
|
result = [[10, 15], [20, 40], [50, 60]] |
|
|
|
|
|
|
|
utils_result = utils.merge_intersecting_intervals(index) |
|
|
|
|
|
|
|
for idx, val in enumerate(utils_result): |
|
|
|
|
|
|
|
self.assertEqual(result[idx][0], val[0]) |
|
|
|
|
|
|
|
self.assertEqual(result[idx][1], val[1]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_intersecting_intervals_6(self): |
|
|
|
|
|
|
|
index = [[20, 40], [10, 20], [50, 60]] |
|
|
|
|
|
|
|
result = [[10, 40], [50, 60]] |
|
|
|
|
|
|
|
utils_result = utils.merge_intersecting_intervals(index) |
|
|
|
|
|
|
|
for idx, val in enumerate(utils_result): |
|
|
|
|
|
|
|
self.assertEqual(result[idx][0], val[0]) |
|
|
|
|
|
|
|
self.assertEqual(result[idx][1], val[1]) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|
unittest.main() |
|
|
|
unittest.main() |
|
|
|