torch_ecg.utils.overlaps

torch_ecg.utils.overlaps(interval: Sequence[Real] | list, another: Sequence[Real] | list) int[source]

Find the overlap between two intervals.

The amount of overlap, in bp between interval and anohter, is returned.

  • If > 0, the number of bp of overlap

  • If 0, they are book-ended

  • If < 0, the distance in bp between them

Parameters:
  • interval (Interval) – The two intervals to compute their overlap.

  • another (Interval) – The two intervals to compute their overlap.

Returns:

Overlap length of two intervals; if < 0, the distance of two intervals.

Return type:

int

Examples

>>> overlaps([1,2], [2,3])
0
>>> overlaps([1,2], [3,4])
-1
>>> overlaps([1,2], [0,3])
1