src.timeInterval
Created on Fri Apr 5 14:05:51 2024
@author: jsatuit
Exceptions
Exception raised when transmit and receive TimeIntervals overlap. |
Classes
Handling one begin and end of the time the transmitter/receiver channel is on. |
|
A hack of base python list class for simpler calling of properties of each |
Module Contents
- exception src.timeInterval.OverlapError(*args)
Bases:
Exception
Exception raised when transmit and receive TimeIntervals overlap.
- class src.timeInterval.TimeInterval(begin=0.0, end=0)
Handling one begin and end of the time the transmitter/receiver channel is on.
- Parameters:
begin (float) – Begin of interval
end (float) – End of interval. Must be after begin
- Raises:
ValueError – when begin of interval comes after end
- begin = 0.0
- end = 0
- __mul__(num)
Multiplies interval begin and end times with num.
- Parameters:
num (float) – Number to multiply with
- Returns:
TimeInterval(begin*num, end*num)
- Return type:
Self
- __truediv__(num)
Divides interval begin and end times with num.
- Parameters:
num (int | float) – Number to divide with
- Returns:
TimeInterval(begin/num, end/num)
- Return type:
Self
- __repr__()
- Return type:
str
- __eq__(other)
- Parameters:
other (Self)
- Return type:
bool
- property length: float
Length/duration of interval
- Return type:
float
- property as_tuple: tuple[float, float]
- Return type:
tuple[float, float]
- overlaps_with(other)
Checks if TimeInterval overlaps with other TimeInterval
- Parameters:
other (TimeInterval) – TimeInterval to check overlap with
- Returns:
True if the intervals overlap, else False
- Return type:
bool
- overlaps_any(other)
Checks if TimeInterval overlaps with any other TimeInterval in list
- Parameters:
other (list[TimeInterval]) – list of TimeInterval objects to check overlap with
- Returns:
True if any intervals overlap, else False
- Return type:
bool
- check_overlap(other)
Checks if TimeInterval overlaps with other TimeInterval. If so, an OverlapError is raised
- Parameters:
other (TimeInterval) – TimeInterval to check overlap with
- Raises:
OverlapError – When intervals overlap
- within(other)
Return True if this interval is within the other interval.
- Intervals are allowed to share boundaries. Numerical errors are not
taken into account
- Parameters:
other (TimeInterval) – Other TimeInterval
- Returns:
whwether this interval is within the other one.
- Return type:
bool
- within_any(other)
Return True if this interval is completely within any of the intervals in the list.
- Intervals are allowed to share boundaries. Numerical errors are not
taken into account
- Parameters:
other (list[TimeInterval]) – List of TimeInterval objects
- Returns:
whwether this interval is within any of those in the list.
- Return type:
bool
- class src.timeInterval.TimeIntervalList
Bases:
list
A hack of base python list class for simpler calling of properties of each TimeInterval in the list.
- listof(attr)
Return list of the attribute attr of each TimeInterval.
See other functions for examples.
- Parameters:
attr (str)
- property lengths: list[float]
list with length of each TimeInterval
- Return type:
list[float]
- property begins: list[float]
list with begin of each TimeInterval
- Return type:
list[float]
- property ends: list[float]
list with end of each TimeInterval
- Return type:
list[float]