torch_ecg.utils.is_intersect

torch_ecg.utils.is_intersect(interval: Sequence[Sequence[Real] | list] | list | Sequence[Real], another_interval: Sequence[Sequence[Real] | list] | list | Sequence[Real]) bool[source]

Determines if two (generalized) intervals intersect or not.

Parameters:
  • interval (GeneralizedInterval or Interval) – The two intervals to check if they intersect.

  • another_interval (GeneralizedInterval or Interval) – The two intervals to check if they intersect.

Returns:

True if interval intersects with another_interval, False otherwise.

Return type:

bool

Examples

>>> is_intersect([0, 10], [5, 15])
True
>>> is_intersect([0, 10], [10, 15])
False
>>> is_intersect([0, 10], [])
False
>>> is_intersect([0, 10], [[5, 20], [25, 30]])
True