BasicTools.Helpers.Search module
Use of bisect to search in sorted lists
from: https://docs.python.org/3.8/library/bisect.html
- BasicTools.Helpers.Search.BinarySearch(ordered_list, item)[source]
- Inspects the sorted list “ordered_list” and returns:
0 if item <= ordered_list[0]
the rank of the largest element smaller or equal than item otherwise
- Parameters:
ordered_list (list or one-dimensional np.ndarray) – the data sorted in increasing order from which the previous rank is searched
item (float or int) – the item for which the previous rank is searched
- Returns:
0 or the rank of the largest element smaller or equal than item in “ordered_list”
- Return type:
int