TTTime

The TTTime class implements the basics of defining intervals.

clock:

object of TTClock type

start_tick:

integer representing the first tick in the interval

stop_tick:

integer representing the first tick beyond the interval

Every valid TTTime spans at least one tick of its clock.

class ticktalkpython.Time.TTTime(clock, start_tick, stop_tick)

Define an interval based on a clock. Ticks must be integers, and the stop_tick must be greater than start_tick

Parameters:
  • clock (TTClock) – the clock with which this time interval is associated

  • start_tick (int) – the first tick of clock corresponding to the beginning of this interval

  • stop_tick (int) – the first tick of the clock following the interval; must be strictly greater than start_tick

ancestor_time(ancestor)

Translate this time into an ancestor’s time: climb from this time’s clock toward root, looking for a match, translating time as we go

Parameters:

ancestor (TTClock) – a clock that is an ancestor to this clock, up to or including the root clock

child_time(child)

Lossy conversion into a child clock’s domain. If the period relating the child and parent is not 1, then information will be lost as time-labels are constructed of integers, meaning that the integer division must truncate. The child doesn’t not have to be the direct child of the clock used in the time label, but it must be a direct descendant.

Parameters:

child (TTClock) – A direct descendant of the clock denoted in the ‘clock’ field of the token.

Returns:

The time in the child domain (potentially with loss of precision)

Return type:

TTTime

static common_ancestor_overlap_time(time_a, time_b)

Find the common ancestor clock for the clocks of each specified time and compute the intersection of the given times in terms of the ancestor, or None if the intersection is empty

Parameters:
  • time_a (TTTime) – one of the times (this method is commutative)

  • time_b (TTTime) – the other time

Returns:

time (interval) representing the intersection

Return type:

TTTime

static common_ancestor_overlap_time_multi(*times)

Find the common ancestor clock for the clocks of each specified time and compute the intersection of the given times in terms of the ancestor, or None if the intersection is empty.

Parameters:

times (TTTime) – list of times

Returns:

time (interval) representing the intersection

Return type:

TTTime

static infinite(clock)

Return an ‘infinite’ time interval with reference to a clock.

Parameters:

clock (TTClock) – the clock to use in the returned time

Returns:

infinite time interval

Return type:

TTTime

n_ticks()

Return the length of the interval in ticks

Returns:

interval length

Return type:

int

class ticktalkpython.Time.TTTimeSpec(clockspec, start_tick: int, stop_tick: int, ensemble_src_name=None)

A TTTimeSpec is a specification for the TTTime, such that it does not contain any direct memory references that would be duplicated when serializing the object before it gets passed through a queue or network interface

Parameters:
  • clockspec (TTClockSpec) – the specification for the clock domain this time resides in

  • start_tick (int) – The start tick of the interval (strictly less than the stop tick)

  • stop_tick (int) – the stop tick of the itnerval (strictly greater than the start tick)

  • ensemble_src_name (string | None) – The name of the ensemble that generated this time interval, defaults to None

to_time(clock=None, clock_list=None)

Convert this timestamp into the equivalent TTTime. If no clock is provided, it will attempt to find it from a clock list, but failing that, will raise a ValueError

Parameters:
  • clock (TTClock) – The clock the TTTime should use. Defaults to None

  • clock_list (list(TTClock)) – A list of clocks to search for the clockspec in. Defaults to an empty list

Returns:

the equivalent TTTime

Return type:

TTTime