tests: add EMA

This commit is contained in:
Casper da Costa-Luis 2020-12-24 21:28:14 +00:00
parent 836f885b50
commit 638e889a08
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 11 additions and 1 deletions

View File

@ -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()