• Github
Table of Contents
0.8.7.1
  • Welcome to PsyNeuLink
  • Basics and Primer
  • Quick Reference
  • Core
  • Library
  • Contributors Guide
  • Docs >
  • Time
Shortcuts

Time¶

Overview¶

Schedulers maintain Clock objects to track time. The current time in relation to a Scheduler is stored in Scheduler.clock.time or Scheduler.clock.simple_time

class psyneulink.core.scheduling.time.Clock¶

Stores a history of TimeScales that have occurred, and keep track of a current Time. Used in relation to a Scheduler

history¶

a root TimeHistoryTree associated with this Clock

Type

TimeHistoryTree

_increment_time(time_scale)¶

Calls self.history.increment_time

get_total_times_relative(query_time_scale, base_time_scale, base_index=None)¶

Convenience simplified wrapper for TimeHistoryTree.get_total_times_relative

Parameters
  • query_time_scale (TimeScale) – the unit of time whose number of ticks to be returned

  • base_time_scale (TimeScale) – the unit of time over which the number of query_time_scale ticks should be returned

  • base_index (int) – the base_indexth base_time_scale over which the number of query_time_scale ticks should be returned

Returns

the number of query_time_scale s that have occurred during the scope of the base_index th base_time_scale

Return type

int

get_time_by_time_scale(time_scale)¶
Parameters

time_scale (TimeScale) –

Returns

the current value of the time unit corresponding to time_scale for this Clock

Return type

int

property time¶

Time

Type

the current time

property simple_time¶

SimpleTime

Type

the current time in simple format

property previous_time¶

Time

Type

the time that has occurred last

class psyneulink.core.scheduling.time.TimeScale(value)¶

Represents divisions of time used by the Scheduler, Conditions, and the time_scale argument of a Composition’s run method.

The values of TimeScale are defined as follows (in order of increasingly coarse granularity):

TIME_STEP¶

the nuclear unit of time, corresponding to the execution of all Mechanisms allowed to execute from a single consideration_set of a Scheduler, and which are considered to have executed simultaneously.

PASS¶

a full iteration through all of the consideration_sets in a Scheduler's consideration_queue, consisting of one or more TIME_STEPs, over which every Component specified to a Scheduler is considered for execution at least once.

TRIAL¶

an open-ended unit of time consisting of all actions that occurs within the scope of a single input to a Composition.

RUN¶

the scope of a call to the run method of a Composition, consisting of one or more TRIALs.

LIFE¶

the scope of time since the creation of an object.

classmethod get_parent(time_scale)¶
Returns

the TimeScale one level wider in scope than time_scale

Return type

TimeScale

classmethod get_child(time_scale)¶
Returns

the TimeScale one level smaller in scope than time_scale

Return type

TimeScale

class psyneulink.core.scheduling.time.Time(time_step=0, pass_=0, trial=0, run=0, life=0)¶

Represents an instance of time, having values for each TimeScale

life¶

the TimeScale.LIFE value

Type

int : 0

run¶

the TimeScale.RUN value

Type

int : 0

trial¶

the TimeScale.TRIAL value

Type

int : 0

pass_¶

the TimeScale.PASS value

Type

int : 0

time_step¶

the TimeScale.TIME_STEP value

Type

int : 0

_get_by_time_scale(time_scale)¶
Parameters

time_scale (TimeScale) –

Returns

this Time’s value of a TimeScale by the TimeScale enum, rather than by attribute

Return type

int

_set_by_time_scale(time_scale, value)¶
Parameters

time_scale (TimeScale) –

Sets this Time’s value of a time_scale by the TimeScale enum, rather than by attribute

_increment_by_time_scale(time_scale)¶

Increments the value of time_scale in this Time by one

_reset_by_time_scale(time_scale)¶

Resets all the times for the time scale scope up to time_scale e.g. _reset_by_time_scale(TimeScale.TRIAL) will set the values for TimeScale.PASS and TimeScale.TIME_STEP to 0

class psyneulink.core.scheduling.time.SimpleTime(run=0, trial=0, time_step=0)¶

A subset class of Time, used to provide simple access to only run, trial, and time_step

class psyneulink.core.scheduling.time.TimeHistoryTree(time_scale=<TimeScale.LIFE: 4>, max_depth=<TimeScale.TRIAL: 2>, index=0, parent=None, enable_current_time=True)¶

A tree object that stores a history of time that has occurred at various TimeScales, typically used in conjunction with a Clock

time_scale¶

the TimeScale unit this tree/node represents

Type

TimeScale : TimeScale.LIFE

child_time_scale¶

the TimeScale unit for this tree’s children

Type

TimeScale : TimeScale.RUN

children¶

an ordered list of this tree’s children

Type

list[TimeHistoryTree]

max_depth¶

the finest grain TimeScale that should be created as a subtree Setting this value lower allows for more precise measurements (by default, you cannot query the number of TimeScale.TIME_STEPs in a certain TimeScale.PASS), but this may use a large amount of memory in large simulations

Type

TimeScale : TimeScale.TRIAL

index¶

the index this tree has in its parent’s children list

Type

int

parent¶

the parent node of this tree, if it exists. None represents no parent (i.e. root node)

Type

TimeHistoryTree : None

previous_time¶

a Time object that represents the last time that has occurred in the tree

Type

Time

current_time¶

a Time object that represents the current time in the tree

Type

Time

total_times¶

stores the total number of units of TimeScales that have occurred over this tree’s scope. Only contains entries for TimeScales of finer grain than time_scale

Type

dict{TimeScale: int}

Parameters

enable_current_time (bool : True) – sets this tree to maintain a Time object. If this tree is not a root (i.e. time_scale is TimeScale.LIFE)

increment_time(time_scale)¶

Increases this tree’s current_time by one time_scale

Parameters

time_scale (TimeScale) – the unit of time to increment

get_total_times_relative(query_time_scale, base_indices=None)¶
Parameters
  • query_time_scale (TimeScale) – the TimeScale of units to be returned

  • base_indices (dict{TimeScale: int}) –

    a dictionary specifying what scope of time query_time_scale is over. e.g.

    base_indices = {TimeScale.RUN: 1, TimeScale.TRIAL: 5}

    gives the number of query_time_scales that have occurred in the 5th TRIAL of the 1st RUN. If an entry for a TimeScale is not specified but is coarser than query_time_scale, the latest value for that entry will be used

Returns

the number of units of query_time_scale that have occurred within the scope of time specified by base_indices

Return type

int

exception psyneulink.core.scheduling.time.TimeScaleError(error_value)¶

© Copyright 2016, Jonathan D. Cohen.

Built with Sphinx using a theme provided by Read the Docs.
  • Time
    • Overview
  • Github