TextProgressBar
class TextProgressBar(output_handler=None)
Bases: qiskit.tools.events.progressbar.BaseProgressBar
A simple text-based progress bar.
output_handlerthe handler the progress bar should be written to, default
is sys.stdout, another option is sys.stderr
Examples
The progress bar can be used to track the progress of a parallel_map.
import numpy as np
import qiskit.tools.jupyter
from qiskit.tools.parallel import parallel_map
from qiskit.tools.events import TextProgressBar
TextProgressBar()
%qiskit_progress_bar -t text
parallel_map(np.sin, np.linspace(0,10,100));
And it can also be used individually.
from qiskit.tools.events import TextProgressBar
iterations = 100
t = TextProgressBar()
t.start(iterations=iterations)
for i in range(iterations):
# step i of heavy calculation ...
t.update(i + 1) # update progress bar
Methods
clear
TextProgressBar.clear()
Unsubscribe everything
finished
TextProgressBar.finished()
Run when progress bar has completed.
start
TextProgressBar.start(iterations)
Start the progress bar.
Parameters
iterations (int) – Number of iterations.
subscribe
TextProgressBar.subscribe(event, callback)
Subscribes to an event, associating a callback function to that event, so when the event occurs, the callback will be called. This is a blocking call, so try to keep callbacks as lightweight as possible.
time_elapsed
TextProgressBar.time_elapsed()
Return the time elapsed since start.
Returns
Time since progress bar started.
Return type
elapsed_time
time_remaining_est
TextProgressBar.time_remaining_est(completed_iter)
Estimate the remaining time left.
Parameters
completed_iter (int) – Number of iterations completed.
Returns
Estimated time remaining.
Return type
est_time
unsubscribe
TextProgressBar.unsubscribe(event, callback)
Unsubscribe a pair event-callback, so the callback will not be called anymore when the event occurs.
update
TextProgressBar.update(n)
Update status of progress bar.