progressbars

Progress indicators that can be called directly or passed to specific themachinethatgoesping functions

class ConsoleProgressBar

Old-school progress bar that prints to terminal. For reference only, might be removed in the future.

This class is based in I_ProgressBarTimed such that the callbacks are guarded by a timer.

__init__(self: ConsoleProgressBar) None
close(self: I_ProgressBar, msg: str = 'done') None

Finalize the progressbar

Parameter msg:

A message that can be appended as postfix

current(self: I_ProgressBar) float

Get the current progress state

Returns

progress state

init(self: I_ProgressBar, first: float, last: float, process_name: str = 'process') None

Initialize a new progressbar within the given range

Parameter first:

lowest number in the range (typically 0.0)

Parameter last:

highest number in the range (typically 100.0)

Parameter process_name:

Name of the progress

set_postfix(self: I_ProgressBar, postfix: str) None

Append a postfix message to the progressbar

Parameter postfix:

postfix message

set_progress(self: I_ProgressBar, progress: float) None

Set the progress state to the given value. Note some implementations may require the new_progress to be higher than the current progress!

Parameter new_progress:

New progress state (within the given first/last range)

tick(self: I_ProgressBar, increment: float = 1) None

Increment the progress state by the given amount

Parameter increment:

Number of steps to increment the progress by

class I_ProgressBar

This is a generic (abstract) class for progress bars. Usage: call init() and close() to initialize and finalize the progress bar. Then call set_progress() or tick() to update the progress bar. set_postfix() can be used to set a postfix message.

Note: Functions the set_progress and tick functions can significantly slow down processes that use the progressbar. Consider using the ProgressBarTimed interface instead.

__init__(self: I_ProgressBar) None

Construct a new i progressbar object

close(self: I_ProgressBar, msg: str = 'done') None

Finalize the progressbar

Parameter msg:

A message that can be appended as postfix

current(self: I_ProgressBar) float

Get the current progress state

Returns

progress state

init(self: I_ProgressBar, first: float, last: float, process_name: str = 'process') None

Initialize a new progressbar within the given range

Parameter first:

lowest number in the range (typically 0.0)

Parameter last:

highest number in the range (typically 100.0)

Parameter process_name:

Name of the progress

set_postfix(self: I_ProgressBar, postfix: str) None

Append a postfix message to the progressbar

Parameter postfix:

postfix message

set_progress(self: I_ProgressBar, progress: float) None

Set the progress state to the given value. Note some implementations may require the new_progress to be higher than the current progress!

Parameter new_progress:

New progress state (within the given first/last range)

tick(self: I_ProgressBar, increment: float = 1) None

Increment the progress state by the given amount

Parameter increment:

Number of steps to increment the progress by

class I_ProgressBarTimed

This is a generic (abstract) class for progress bars. Usage: call init() and close() to initialize and finalize the progress bar. Then call set_progress() or tick() to update the progress bar. set_postfix() can be used to set a postfix message. *

The above name functions are guarded by a timer (100ms). The timer is started when calling set_progress() or tick(). Repetitively calling of these functions (in a loop) will update the internal state but not update the progress bar until the timer (100ms) expires.

This ensures a low overhead even for slow progressbar implementations.

All functions are thread-safe.

To implement this interface the abstract callback_ functions must be implemented.

__init__(self: I_ProgressBarTimed) None
callback_close(self: I_ProgressBarTimed, msg: str = 'done') None

Finalize the progressbar

Parameter msg:

A message that can be appended as postfix

callback_current(self: I_ProgressBarTimed) float

Get the current progress state

Returns

progress state

callback_init(self: I_ProgressBarTimed, first: float, last: float, process_name: str = 'process') None

Initialize a new progressbar within the given range

Parameter first:

lowest number in the range (typically 0.0)

Parameter last:

highest number in the range (typically 100.0)

Parameter process_name:

Name of the progress

callback_set_postfix(self: I_ProgressBarTimed, postfix: str) None

Append a postfix message to the progressbar

This callback is guarded by a timer (100ms). If skipped, the postfix is stored to the internal state and will be applied with the next successful call to set_progress(), tick() or set_postfix().

Parameter postfix:

postfix message

callback_set_progress(self: I_ProgressBarTimed, progress: float) None

Set the progress state to the given value. Note some implementations may require the new_progress to be higher than the current progress!

This callback is guarded by a timer (100ms). If skipped, the progress is stored to the internal state and will be applied with the next successful call to set_progress(), tick() or set_postfix().

Parameter new_progress:

New progress state (within the given first/last range)

callback_tick(self: I_ProgressBarTimed, increment: float = 1) None

Increment the progress state by the given amount This callback is guarded a timer (100ms).

If skipped, the increment is added to the internal counter and will be applied with the next unskipped call to tick().

Parameter increment:

Number of steps to increment the progress by

close(self: I_ProgressBar, msg: str = 'done') None

Finalize the progressbar

Parameter msg:

A message that can be appended as postfix

current(self: I_ProgressBar) float

Get the current progress state

Returns

progress state

init(self: I_ProgressBar, first: float, last: float, process_name: str = 'process') None

Initialize a new progressbar within the given range

Parameter first:

lowest number in the range (typically 0.0)

Parameter last:

highest number in the range (typically 100.0)

Parameter process_name:

Name of the progress

set_postfix(self: I_ProgressBar, postfix: str) None

Append a postfix message to the progressbar

Parameter postfix:

postfix message

set_progress(self: I_ProgressBar, progress: float) None

Set the progress state to the given value. Note some implementations may require the new_progress to be higher than the current progress!

Parameter new_progress:

New progress state (within the given first/last range)

tick(self: I_ProgressBar, increment: float = 1) None

Increment the progress state by the given amount

Parameter increment:

Number of steps to increment the progress by

class NoIndicator

A progress bar that does not show any progress and has nearly no overhead.

__init__(self: NoIndicator) None
close(self: I_ProgressBar, msg: str = 'done') None

Finalize the progressbar

Parameter msg:

A message that can be appended as postfix

current(self: I_ProgressBar) float

Get the current progress state

Returns

progress state

init(self: I_ProgressBar, first: float, last: float, process_name: str = 'process') None

Initialize a new progressbar within the given range

Parameter first:

lowest number in the range (typically 0.0)

Parameter last:

highest number in the range (typically 100.0)

Parameter process_name:

Name of the progress

set_postfix(self: I_ProgressBar, postfix: str) None

Append a postfix message to the progressbar

Parameter postfix:

postfix message

set_progress(self: I_ProgressBar, progress: float) None

Set the progress state to the given value. Note some implementations may require the new_progress to be higher than the current progress!

Parameter new_progress:

New progress state (within the given first/last range)

tick(self: I_ProgressBar, increment: float = 1) None

Increment the progress state by the given amount

Parameter increment:

Number of steps to increment the progress by

class ProgressIndicator

Text based ProgressBar that uses the indicators library. (https://github.com/p-ranav/indicators)

This class is based in I_ProgressBarTimed such that the callbacks are guarded by a timer.

__init__(self: ProgressIndicator) None
close(self: I_ProgressBar, msg: str = 'done') None

Finalize the progressbar

Parameter msg:

A message that can be appended as postfix

current(self: I_ProgressBar) float

Get the current progress state

Returns

progress state

init(self: I_ProgressBar, first: float, last: float, process_name: str = 'process') None

Initialize a new progressbar within the given range

Parameter first:

lowest number in the range (typically 0.0)

Parameter last:

highest number in the range (typically 100.0)

Parameter process_name:

Name of the progress

set_postfix(self: I_ProgressBar, postfix: str) None

Append a postfix message to the progressbar

Parameter postfix:

postfix message

set_progress(self: I_ProgressBar, progress: float) None

Set the progress state to the given value. Note some implementations may require the new_progress to be higher than the current progress!

Parameter new_progress:

New progress state (within the given first/last range)

tick(self: I_ProgressBar, increment: float = 1) None

Increment the progress state by the given amount

Parameter increment:

Number of steps to increment the progress by

class ProgressTqdm

Python ProgressBar that uses the tqdm. This is a test implementation for reference only. Do not use in production! Including this header will result in a compilation error if the project is not linked against pybind11 (not default for themachinethatgoesping_tools).

This class is based in I_ProgressBarTimed such that the callbacks are guarded by a timer.

__init__(self: ProgressTqdm, tqdm: object) None

Construct a new Progress Tqdm object To initialize a tqdm object call: from tqdm import tqdm, and use tqdm()

Parameter tqdm:

A python tqdm class object

close(self: I_ProgressBar, msg: str = 'done') None

Finalize the progressbar

Parameter msg:

A message that can be appended as postfix

current(self: I_ProgressBar) float

Get the current progress state

Returns

progress state

init(self: I_ProgressBar, first: float, last: float, process_name: str = 'process') None

Initialize a new progressbar within the given range

Parameter first:

lowest number in the range (typically 0.0)

Parameter last:

highest number in the range (typically 100.0)

Parameter process_name:

Name of the progress

set_postfix(self: I_ProgressBar, postfix: str) None

Append a postfix message to the progressbar

Parameter postfix:

postfix message

set_progress(self: I_ProgressBar, progress: float) None

Set the progress state to the given value. Note some implementations may require the new_progress to be higher than the current progress!

Parameter new_progress:

New progress state (within the given first/last range)

tick(self: I_ProgressBar, increment: float = 1) None

Increment the progress state by the given amount

Parameter increment:

Number of steps to increment the progress by

test_loop(ProgressBar: I_ProgressBar, loops: int = 1000, sleep_us: int = 10, show_progress: bool = True) float