torch_ecg.utils.in_interval¶
- torch_ecg.utils.in_interval(val: Real, interval: Sequence[Real] | list, left_closed: bool = True, right_closed: bool = False) bool [source]¶
Check whether val is inside interval or not.
- Parameters:
val (numbers.Real) – The value to be checked.
interval (Interval) – The interval to be checked.
left_closed (bool, default True) – Whether the left end of interval is closed.
right_closed (bool, default False) – Whether the right end of interval is closed.
- Returns:
Whether val is inside generalized_interval or not.
- Return type:
Examples
>>> in_interval(-1.3, [0, 2]) False >>> in_interval(1.5, [1, 2]) True >>> in_interval(1, [1, 2]) True >>> in_interval(1, [1, 2], left_closed=False) False >>> in_interval(2, [1, 2]) False >>> in_interval(2, [1, 2], right_closed=True) True