SolveTimer#
- class SolveTimer(*_, **__)[source]#
Progress indicator for model optimization.
Examples
Print timer and number of iterations in console while running ml.solve():
with SolveTimer() as t: ml.solve(callback=t.timer)
This prints the following to the console, for example:
Optimization progress: 73it [00:01, 67.68it/s]
Set maximum allowable time (in seconds) for solve, otherwise raise ExceededMaxSolveTime exception:
with SolveTimer(max_time=60) as t: ml.solve(callback=t.timer)
Notes
If the logger is also printing messages to the console the timer will not be updated quite as nicely.
Attributes#
|
Public API for read-only member access. |
|
|
|
Methods#
Initialize SolveTimer. |
|
Wrapper for asyncio.as_completed. |
|
Clear current bar display. |
|
Cleanup and (if leave=False) close the progressbar. |
|
Use self.sp to display msg in the specified pos. |
|
Disable tqdm within context and refresh tqdm when exits. |
|
Formats a number of seconds as a clock time, [H:]MM:SS |
|
Return a string-based progress bar given some parameters |
|
Intelligent scientific notation (.3g). |
|
Formats a number (greater than unity) with SI Order of Magnitude prefixes. |
|
Wrapper for asyncio.gather. |
|
Get the global lock. |
|
Registers the current tqdm class with |
|
Force refresh the display of this bar. |
|
Resets to 0 iterations for repeated use. |
|
Set/modify description of the progress bar. |
|
Set/modify description without ': ' appended. |
|
Set the global lock. |
|
Set/modify postfix (additional stats) with automatic formatting based on datatype. |
|
Postfix without dictionary expansion, similar to prefix handling. |
|
Manage the printing and in-place updating of a line of characters. |
|
Callback method for ps.Model.solve(). |
|
Restart tqdm timer from last print time. |
|
Manually update the progress bar, useful for streams such as reading files. |
|
stream : file-like object. method : str, "read" or "write". The result of read() and the first argument of write() should have a len(). |
|
Print a message via tqdm (without overlap with bars). |