<s> from unittest import TestCase <EOL> from metrology . stats . ewma import EWMA <EOL> class EwmaTest ( TestCase ) : <EOL> def _one_minute ( self , ewma ) : <EOL> for i in range ( <NUM_LIT:12> ) : <EOL> ewma . tick ( ) <EOL> def test_one_minute_ewma ( self ) : <EOL> ewma = EWMA . m1 ( ) <EOL> ewma . update ( <NUM_LIT:3> ) <EOL> ewma . tick ( ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT> , places = <NUM_LIT:6> ) <EOL> self . _one_minute ( ewma ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT> , places = <NUM_LIT:6> ) <EOL> self . _one_minute ( ewma ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT> , places = <NUM_LIT:6> ) <EOL> def test_five_minute_ewma ( self ) : <EOL> ewma = EWMA . m5 ( ) <EOL> ewma . update ( <NUM_LIT:3> ) <EOL> ewma . tick ( ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT> , places = <NUM_LIT:6> ) <EOL> self . _one_minute ( ewma ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT> , places = <NUM_LIT:6> ) <EOL> self . _one_minute ( ewma ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT> , places = <NUM_LIT:6> ) <EOL> def test_fifteen_minute_ewma ( self ) : <EOL> ewma = EWMA . m15 ( ) <EOL> ewma . update ( <NUM_LIT:3> ) <EOL> ewma . tick ( ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT> , places = <NUM_LIT:6> ) <EOL> self . _one_minute ( ewma ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT> , places = <NUM_LIT:6> ) <EOL> self . _one_minute ( ewma ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT> , places = <NUM_LIT:6> ) <EOL> def test_clear_ewma ( self ) : <EOL> ewma = EWMA . m15 ( ) <EOL> ewma . update ( <NUM_LIT:3> ) <EOL> ewma . tick ( ) <EOL> ewma . clear ( ) <EOL> self . assertAlmostEqual ( ewma . rate , <NUM_LIT:0> ) </s>
