timing
Utilities for keeping track of time in a task.
- class axopy.timing.Counter(max_count=1, reset_on_timeout=True)[source]
Counts to a given number then transmits a timeout event.
- Parameters:
- timeout
Transmitted when
max_count
has been reached.- Type:
Transmitter
Examples
Basic usage:
>>> from axopy.timing import Counter >>> timer = Counter(2) >>> timer.increment() >>> timer.count 1 >>> timer.progress 0.5 >>> timer.increment() >>> timer.count 0
- increment()[source]
Increment the counter.
If max_count is reached, the
timeout
event is transmitted. If reset_on_timeout has been set to True (default), the timer is also reset.
- property progress
Progress toward timeout, from 0 to 1.
- class axopy.timing.Timer(duration)[source]
Real-time one-shot timer.
This is useful in situations where you want to wait for some amount of time and locking the timing to data acquisition updates is not important. For example, inserting a waiting period between trials of a task can be done by connecting the
timeout
transmitter to your task’snext_trial()
method.- Parameters:
duration (float) – Duration of the timer, in seconds.
- timeout
Transmitted when the timer has finished.
- Type:
Transmitter