Progress reporting

class brian.utils.progressreporting.ProgressReporter(report='stderr', period=10.0, first_report=-1.0)

Standard text and graphical progress reports

Initialised with arguments:


Can be one of the following strings:

'print', 'text', 'stdout'
Reports progress to standard console.
Reports progress to error console.
'graphical', 'tkinter'
A simple graphical progress bar using Tkinter.

Alternatively, it can be any output stream in which case text reports will be sent to it, or a custom callback function report(elapsed, complete) taking arguments elapsed the amount of time that has passed and complete the fraction of the computation finished.

How often reports should be generated in seconds.
The time of the first report (nothing will be done before this amount of time has elapsed).



Call at the beginning of a task to start timing it.


Call at the end of a task to finish timing it. Note that with the Tkinter class, if you do not call this it will stop the Python script from finishing, stopping memory from being freed up.


Call with the fraction of the task (or subtask if subtask() has been called) completed, between 0 and 1.

subtask(complete, tasksize)

After calling subtask(complete, tasksize), subsequent calls to update will report progress between a fraction complete and complete+tasksize of the total task. complete represents the amount of the total task completed at the beginning of the task, and tasksize the size of the subtask as a proportion of the whole task.

equal_subtask(tasknum, numtasks)

If a task can be divided into numtasks equally sized subtasks, you can use this method instead of subtask, where tasknum is the number of the subtask about to start.

Note that in Python 2.6+, this can be used as a context manager, and it will automatically call the start() and finish() methods at the beginning and end, e.g.:

with ProgressReporter(period=0.1) as progress:
    for i in xrange(10):