mirror of https://github.com/tqdm/tqdm.git
tests: add EMA
This commit is contained in:
parent
836f885b50
commit
638e889a08
|
@ -15,7 +15,7 @@ from warnings import catch_warnings, simplefilter
|
|||
from tqdm import tqdm
|
||||
from tqdm import trange
|
||||
from tqdm import TqdmDeprecationWarning, TqdmWarning
|
||||
from tqdm.std import Bar
|
||||
from tqdm.std import Bar, EMA
|
||||
from tqdm.contrib import DummyTqdmFile
|
||||
|
||||
try:
|
||||
|
@ -1004,6 +1004,16 @@ def test_close():
|
|||
t.close()
|
||||
|
||||
|
||||
def test_ema():
|
||||
"""Test exponential weighted average"""
|
||||
ema = EMA(0.01)
|
||||
assert round(ema(10), 2) == 10
|
||||
assert round(ema(1), 2) == 5.48
|
||||
assert round(ema(), 2) == 5.48
|
||||
assert round(ema(1), 2) == 3.97
|
||||
assert round(ema(1), 2) == 3.22
|
||||
|
||||
|
||||
def test_smoothing():
|
||||
"""Test exponential weighted average smoothing"""
|
||||
timer = DiscreteTimer()
|
||||
|
|
Loading…
Reference in New Issue