radis.misc.progress_bar module¶
Created on Wed Oct 18 15:38:14 2017.
@author: erwan
- class ProgressBar(N, active=True, t0=None)[source]¶
Bases:
object
Writes completion status and expended time.
Set it up by creating the object, then calling
update()
anddone()
.- Parameters:
N (int) â (expected) number of iterations
active (bool) â if
False
, do not show anything (tip : feed it averbose
argument)
- Other Parameters:
t0 (float) â initializes starting time at
t0
(useful for successive loops)
Example
add a progress bar in a loop:
pb = ProgressBar(N) for i, ... in enumerate(...): (...) pb.update(i) pb.done()
See test in progress_bar.py
- set_active(active=True)[source]¶
Option to activate/deactivate the ProgressBar.
Used not to make it appear on small processes (based on a condition) without changing most of the code
- update(i, modulo=1, message='')[source]¶
Update the completion status i/N and time spent.
- Parameters:
i (int) â current iteration
modulo (int) â if higher than
1
, skip some iterations.message (str) â add a custom message. Tip: evaluate your own variables with fâ{my_variable}â strings
Example