mappymatch.matchers.lcss.utils#
Functions
|
Compress a list of cutting points if they happen to be directly adjacent to another |
|
Helper function to merge items in a list by adding them to the next eligible element. |
|
Combines the forward and reverse merges to catch edge cases at the tail ends of the list |
|
Helper function to merge items in a list by adding them to the next eligible element. |
- mappymatch.matchers.lcss.utils.forward_merge(merge_list, condition)[source]#
Helper function to merge items in a list by adding them to the next eligible element. This merge moves left to right.
For example, given the list:
[1, 2, 3, 4, 5]
And the condition, x < 3, the function yields:
- Return type:
List
- Parameters:
merge_list (List)
condition (Callable[[Any], bool])
>>> forward_merge([1,2,3,4,5], lambda x: x < 3) >>> [6, 4, 5]
- Args:
merge_list: the list to merge condition: the merge condition
- Returns:
a list of the merged items
- mappymatch.matchers.lcss.utils.reverse_merge(merge_list, condition)[source]#
Helper function to merge items in a list by adding them to the next eligible element. This merge moves right to left.
For example, given the list:
[1, 2, 3, 4, 5]
And the condition, x < 3, the function yields:
- Return type:
List
- Parameters:
merge_list (List)
condition (Callable[[Any], bool])
>>> list(reverse_merge([1,2,3,4,5], lambda x: x < 3)) >>> [3, 3, 4, 5]
- Args:
merge_list: the list to merge condition: the merge condition
- Returns:
a list of the merged items
- mappymatch.matchers.lcss.utils.merge(merge_list, condition)[source]#
Combines the forward and reverse merges to catch edge cases at the tail ends of the list
- Return type:
List
- Parameters:
merge_list (List)
condition (Callable[[Any], bool])
- Args:
merge_list: the list to merge condition: the merge condition
- Returns:
a list of the merged items
- mappymatch.matchers.lcss.utils.compress(cutting_points)[source]#
Compress a list of cutting points if they happen to be directly adjacent to another
- Return type:
Generator
- Parameters:
cutting_points (List)
- Args:
cutting_points: the list of cutting points
- Returns:
a generator of compressed cutting points