Progress Bars

Progress bar implementations

The default implementations of progress bars are listed here, these are the classes that should be used by users.

Note

See ProgressBar for more info on how to use its implementations.

class ConsoleProgressBar(nsteps, width=70)[source]

A text-based progress bar for in a terminal or console

Parameters
  • nsteps (int) – The number of steps that the progressbar will go through

  • width (int, optional) – The width of the progress bar (default: 70)

Progress bar Interface

These are the classes that should be used when creating a custom progress bar.

class ProgressBar(nsteps)[source]

Base class that provides an interface for progress bars

To create a progress bar, create an instance of one of its implementations. The progressbar can then be updated by calling the method update().

To implement a new progress bar, create a class that derives from ProgressBar and implement the method draw(). This method should draw the progress bar based on the accessible member variables. If you need to do anything once in the beginning or the and, you can override the setup() and/or teardown() methods respectively.

Warning

The update() method should not be overwritten.

Parameters

nsteps (int) – The number of steps that the progressbar will go through

nsteps

The number of steps that the progressbar will go through

Type

int

step

The current step of the iteration, going from 0 to nsteps

Type

int

start_time

The start time of the progress bar in seconds since Epoch

Type

float

current_time

The current time of the progress bar in seconds since Epoch

Type

float

progress()[source]

Get the progress as a number between 0 and 1

Returns

The progress

Return type

float

update(step=None)[source]

Update the progressbar

Parameters

step (int, optional) – The current step of the operation, the progress will be increased with one step if not provided (default: None)