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() and done().

Parameters:
  • N (int) – (expected) number of iterations

  • active (bool) – if False, do not show anything (tip : feed it a verbose 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

done()[source]¶

Close the Progress bar.

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