borsar.utils.find_range

borsar.utils.find_range(vec, ranges)[source]

Find specified ranges in an ordered vector and return them as slices.

Parameters:
vec : numpy array

Vector of sorted values.

ranges: list of tuples/lists | two-element list/tuple

Ranges or range to be found.

Returns:
slices : slice or list of slices

Slices representing the ranges. If one range was passed the output is a slice. If two or more ranges were passed the output is a list of slices.