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:
report
Can be one of the following strings:
'print'
,'text'
,'stdout'
- Reports progress to standard console.
'stderr'
- 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 argumentselapsed
the amount of time that has passed andcomplete
the fraction of the computation finished.period
- How often reports should be generated in seconds.
first_report
- The time of the first report (nothing will be done before this amount of time has elapsed).
Methods:
-
start
()¶ Call at the beginning of a task to start timing it.
-
finish
()¶ 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.
-
update
(complete)¶ 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 fractioncomplete
andcomplete+tasksize
of the total task.complete
represents the amount of the total task completed at the beginning of the task, andtasksize
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 ofsubtask
, wheretasknum
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()
andfinish()
methods at the beginning and end, e.g.:with ProgressReporter(period=0.1) as progress: for i in xrange(10): time.sleep(1) progress.update((i+1.0)/10)