mosaik.tiered_time — internal time representation

class TieredDuration(*tiers: 'int', cutoff: 'int | None' = None, pre_length: 'int | None' = None)[source]
Parameters:
class TieredTime(*tiers: 'int')[source]
Parameters:

tiers (tuple[int, ...])

class MinimalDurations(duration=None)[source]

A set of minimal TieredDurations.

Because tiered durations are not always comparable, a set of them does not always have a unique minimum. (However, for a given length and pre-length, the number of minimal elements is at most min(length, pre-length).)

This class represents a set of minimal elements. In other words, the elements of durations are pairwise incomparable. When a new duration is insert`ed, `durations will be updated to contain the minimal elements among all elements seen so far.

Parameters:

duration (TieredDuration | None)

durations: set[TieredDuration][source]

All the minimal durations. Invariant: No two durations in this set are comparable.

insert(duration)[source]

Insert a TieredDuration into the minimal duration set. If the new duration is bigger than any existing one, nothing happens. Otherwise, all exisiting durations that are bigger than the new one are removed and the new one is added to the set. (Incomparable existing duration are not touched.)

Returns whether the set of durations was changed.

Parameters:

duration (TieredDuration)

Return type:

bool

is_time_shifted()[source]

Whether this MinimalDurations is time-shifted, i.e. there is a non-zero first component in any (equivalently, all) of its Durations.

Return type:

bool

is_weak()[source]

Whether this MinimalDurations is weak, i.e. not time-shifted but also not zero.

Return type:

bool

earliest_sum(other)[source]

Add other to all durations in this set and return the minimal result.

Parameters:

other (TieredTime)

Return type:

TieredTime