tlo.progressbar module
Progress bar for visualising progress of simulation runs.
- class ProgressBar(n_step: int, description: str | None = None, n_col: int = 10, unit: str = 'step', min_refresh_time: float = 1.0)
Bases:
object
Iterable object for tracking progress of an iterative task.
Implements both string and HTML representations to allow richer display in interfaces which support HTML output, for example Jupyter notebooks or interactive terminals.
- Parameters:
n_step – Total number of steps in task.
description – Description of task to prefix progress bar with.
n_col – Number of columns (characters) to use in string representation of progress bar.
unit – String describing unit of each step.
min_referesh_time – Minimum time in seconds between each refresh of progress bar visual representation.
- GLYPHS = ' ▏▎▍▌▋▊▉█'
Characters used to create string representation of progress bar.
- property n_step
Total number of steps in task.
- property description
“Description of task being tracked.
- property step
Progress step count.
- property prop_complete
Proportion complete (float value in [0, 1]).
- property perc_complete
Percentage complete formatted as string.
- property elapsed_time
Elapsed time formatted as string.
- property iter_rate
Mean iteration rate if ≥ 1 unit/s or reciprocal s/unit as string.
- property est_remaining_time
Estimated remaining time to completion formatted as string.
- property n_block_filled
Number of filled blocks in progress bar.
- property n_block_empty
Number of empty blocks in progress bar.
- property prop_partial_block
Proportion filled in partial block in progress bar.
- property filled_blocks
Filled blocks string.
- property empty_blocks
Empty blocks string.
- property partial_block
Partial block character.
- property progress_bar
Progress bar string.
- property bar_color
CSS color property for HTML progress bar.
- property stats
Comma-delimited string list of statistic key=value pairs.
- property prefix
Text to prefix progress bar with.
- property postfix
Text to postfix progress bar with.
- reset()
Reset progress bar state.
- update(step: int, stats_dict: Dict | None = None, refresh: bool = True)
Update progress bar state.
- Parameters:
step – New value for step counter.
stats_dict – Dictionary of statistic key-value pairs to use to update postfix stats.
refresh – Whether to refresh display.
- refresh()
Refresh visual display(s) of progress bar.
- start()
Start tracking progress of task.
- stop()
Stop tracking progress of task.
- class StreamDisplay(io: TextIO | None = None)
Bases:
object
Base class for using I/O streams as an updatable display.
- Parameters:
io – I/O stream to write updates to. Defaults to sys.stdout if None.
- close()
- update(obj)
Update display with string representation of obj.
- class AnsiStreamDisplay(io: TextIO | None = None)
Bases:
StreamDisplay
Use I/O stream which supports ANSI escape sequences as an updatable display.
- Parameters:
io – I/O stream to write updates to. Defaults to sys.stdout if None.
- update(obj)
Update display with string representation of obj.
- class BasicStreamDisplay(io: TextIO | None = None)
Bases:
StreamDisplay
Use I/O stream without ANSI escape sequence support as an updatable display.
- Parameters:
io – I/O stream to write updates to. Defaults to sys.stdout if None.
- update(obj)
Update display with string representation of obj.