Skip to content

Commit

Permalink
Added smoothing eta to fix #280. The previous algorithm could be real…
Browse files Browse the repository at this point in the history
…ly jumpy in some cases and has been replaced with an exponential moving average. Double exponential moving average is also available
  • Loading branch information
wolph committed Jan 17, 2024
1 parent 7dff419 commit 3255182
Show file tree
Hide file tree
Showing 4 changed files with 301 additions and 245 deletions.
12 changes: 8 additions & 4 deletions examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,17 @@ def eta_types_demonstration():
progressbar.Percentage(),
' ETA: ',
progressbar.ETA(),
' Adaptive ETA: ',
' Adaptive : ',
progressbar.AdaptiveETA(),
' Absolute ETA: ',
' Smoothing(a=0.1): ',
progressbar.SmoothingETA(smoothing_parameters=dict(alpha=0.1)),
' Smoothing(a=0.9): ',
progressbar.SmoothingETA(smoothing_parameters=dict(alpha=0.9)),
' Absolute: ',
progressbar.AbsoluteETA(),
' Transfer Speed: ',
' Transfer: ',
progressbar.FileTransferSpeed(),
' Adaptive Transfer Speed: ',
' Adaptive T: ',
progressbar.AdaptiveTransferSpeed(),
' ',
progressbar.Bar(),
Expand Down
7 changes: 7 additions & 0 deletions progressbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
from .shortcuts import progressbar
from .terminal.stream import LineOffsetStreamWrapper
from .utils import len_color, streams
from .algorithms import ExponentialMovingAverage, SmoothingAlgorithm, DoubleExponentialMovingAverage
from .widgets import (
ETA,
AbsoluteETA,
AdaptiveETA,
SmoothingETA,
AdaptiveTransferSpeed,
AnimatedMarker,
Bar,
Expand All @@ -36,6 +38,7 @@
Variable,
VariableMixin,
)
from .algorithms import ExponentialMovingAverage, SmoothingAlgorithm

__date__ = str(date.today())
__all__ = [
Expand All @@ -46,6 +49,10 @@
'ETA',
'AdaptiveETA',
'AbsoluteETA',
'SmoothingETA',
'SmoothingAlgorithm',
'ExponentialMovingAverage',
'DoubleExponentialMovingAverage',
'DataSize',
'FileTransferSpeed',
'AdaptiveTransferSpeed',
Expand Down
4 changes: 2 additions & 2 deletions progressbar/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ def default_widgets(self):
' ',
widgets.Timer(**self.widget_kwargs),
' ',
widgets.AdaptiveETA(**self.widget_kwargs),
widgets.SmoothingETA(**self.widget_kwargs),
]
else:
return [
Expand Down Expand Up @@ -1071,7 +1071,7 @@ def default_widgets(self):
' ',
widgets.Timer(),
' ',
widgets.AdaptiveETA(),
widgets.SmoothingETA(),
]
else:
return [
Expand Down
Loading

0 comments on commit 3255182

Please sign in to comment.