exacttiming¶
This module contains the following classes:
TimeValue, a numeric type to represent time values with arbitrary precision.TimeInterval, representing a time interval, that is, a pair(begin, end)of time points.
New in version 1.5.0.
-
class
aeneas.exacttiming.TimeInterval(begin, end)[source]¶ A type representing a time interval, that is, a pair
(begin, end)of time points.This class has some convenience methods for calculating the length of interval, whether a given time point belongs to it, etc.
New in version 1.7.0.
Parameters: Raises: - TypeError – if
beginorendare not instances ofTimeValue - ValueError – if
beginis negative or ifbeginis bigger thanend
-
contains(time_point)[source]¶ Returns
Trueif this interval contains the given time point.Parameters: time_point ( TimeValue) – the time point to testReturn type: bool
-
ends_at(time_point)[source]¶ Returns
Trueif this interval ends at the given time point.Parameters: time_point ( TimeValue) – the time point to testRaises: TypeError – if time_pointis not an instance ofTimeValueReturn type: bool
-
has_zero_length¶ Returns
Trueif this interval has zero length, that is, if its begin and end values coincide.Return type: bool
-
inner_contains(time_point)[source]¶ Returns
Trueif this interval contains the given time point, excluding its extrema (begin and end).Parameters: time_point ( TimeValue) – the time point to testReturn type: bool
-
intersection(other)[source]¶ Return the intersection between this time interval and the given time interval, or
Noneif the two intervals do not overlap.Return type: TimeIntervalorNoneType
-
is_adjacent_after(other)[source]¶ Return
Trueif this time interval begins when the given other time interval ends.Parameters: other ( TimeInterval) – the other intervalRaises: TypeError – if otheris not an instance ofTimeIntervalReturn type: bool
-
is_adjacent_before(other)[source]¶ Return
Trueif this time interval ends when the given other time interval begins.Parameters: other ( TimeInterval) – the other intervalRaises: TypeError – if otheris not an instance ofTimeIntervalReturn type: bool
-
is_non_zero_after_non_zero(other)[source]¶ Return
Trueif this time interval begins when the given other time interval ends, and both have non zero length.Parameters: other ( TimeInterval) – the other intervalRaises: TypeError – if otheris not an instance ofTimeIntervalReturn type: bool
-
is_non_zero_before_non_zero(other)[source]¶ Return
Trueif this time interval ends when the given other time interval begins, and both have non zero length.Parameters: other ( TimeInterval) – the other intervalRaises: TypeError – if otheris not an instance ofTimeIntervalReturn type: bool
-
length¶ Return the length of this interval, that is, the difference between its end and begin values.
Return type: TimeValue
-
offset(offset, allow_negative=False, min_begin_value=None, max_end_value=None)[source]¶ Move this interval by the given shift
offset.The begin and end time points of the translated interval are ensured to be non-negative (i.e., they are maxed with
0.000), unlessallow_negativeis set toTrue.Parameters: - offset (
TimeValue) – the shift to be applied - allow_negative (bool) – if
True, allow the translated interval to have negative extrema - min_begin_value (
TimeValue) – if notNone, specify the minimum value for the begin of the translated interval - max_begin_value (
TimeValue) – if notNone, specify the maximum value for the end of the translated interval
Raises: TypeError – if
offsetis not an instance ofTimeValueReturn type: - offset (
-
overlaps(other)[source]¶ Return
Trueif the given time interval overlaps this time interval (possibly only at an extremum).Parameters: other ( TimeInterval) – the other intervalReturn type: bool
-
percent_value(percent)[source]¶ Returns the time value at
percentof this interval.Parameters: percent ( Decimal) – the percentRaises: TypeError – if time_pointis not an instance ofTimeValueReturn type: TimeValue
-
relative_position_of(other)[source]¶ Return the position of the given other time interval, relative to this time interval, as a
RELATIVE_POSITION_*constant.Parameters: other ( TimeInterval) – the other intervalReturn type: int
-
relative_position_wrt(other)[source]¶ Return the position of this interval, relative to the given other time interval, as a
RELATIVE_POSITION_*constant.Parameters: other ( TimeInterval) – the other intervalReturn type: int
- TypeError – if
-
class
aeneas.exacttiming.TimeValue[source]¶ A numeric type to represent time values with arbitrary precision.
-
geq_multiple(other)[source]¶ Return the next multiple of this time value, greater than or equal to
other. Ifotheris zero, return this time value.Return type: TimeValue
-
is_integer¶ Return
Trueif this time value represents an integer.Return type: bool
-