torch_ecg.utils.in_generalized_interval

torch_ecg.utils.in_generalized_interval(val: Real, generalized_interval: Sequence[Sequence[Real] | list] | list, left_closed: bool = True, right_closed: bool = False) bool[source]

Check whether val is inside generalized_interval or not.

Parameters:
  • val (numbers.Real) – The value to be checked whether it is inside generalized_interval or not.

  • generalized_interval (GeneralizedInterval) – The interval to be checked.

  • left_closed (bool, default True) – Whether the left end of generalized_interval is closed or not.

  • right_closed (bool, default False) – Whether the right end of generalized_interval is closed or not.

Returns:

Whether val is inside generalized_interval or not.

Return type:

bool

Examples

>>> in_generalized_interval(1.5, [[1, 2], [3, 4]])
True
>>> in_generalized_interval(2.5, [[1, 3], [2, 4]])
True
>>> in_generalized_interval(3.45, [[1, 3], [4, 6.9]])
False
>>> in_generalized_interval(0, [[0, 1], [3, 4]])
True
>>> in_generalized_interval(0, [[0, 1], [3, 4]], left_closed=False)
False
>>> in_generalized_interval(1, [[0, 1], [3, 4]])
False
>>> in_generalized_interval(1, [[0, 1], [3, 4]], right_closed=True)
True