<s> from __future__ import division , absolute_import <EOL> import mock <EOL> from unittest2 import TestCase <EOL> from yunomi . compat import xrange <EOL> from yunomi . stats . ewma import EWMA <EOL> class EWMATests ( TestCase ) : <EOL> def elapse_minute ( self , time_mock ) : <EOL> for i in xrange ( <NUM_LIT:0> , <NUM_LIT:12> ) : <EOL> time_mock . return_value += <NUM_LIT:5> <EOL> self . ewma . tick ( ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_one_minute_EWMA_five_sec_tick ( self , time_mock ) : <EOL> time_mock . return_value = <NUM_LIT:0.0> <EOL> self . ewma = EWMA . one_minute_EWMA ( ) <EOL> self . ewma . update ( <NUM_LIT:3> ) <EOL> time_mock . return_value += <NUM_LIT:5> <EOL> self . ewma . tick ( ) <EOL> for expected_rate in [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] : <EOL> self . assertAlmostEqual ( self . ewma . get_rate ( ) , expected_rate ) <EOL> self . elapse_minute ( time_mock ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_five_minute_EWMA_five_sec_tick ( self , time_mock ) : <EOL> time_mock . return_value = <NUM_LIT:0.0> <EOL> self . ewma = EWMA . five_minute_EWMA ( ) <EOL> self . ewma . update ( <NUM_LIT:3> ) <EOL> time_mock . return_value += <NUM_LIT:5> <EOL> self . ewma . tick ( ) <EOL> for expected_rate in [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] : <EOL> self . assertAlmostEqual ( self . ewma . get_rate ( ) , expected_rate ) <EOL> self . elapse_minute ( time_mock ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_fifteen_minute_EWMA_five_sec_tick ( self , time_mock ) : <EOL> time_mock . return_value = <NUM_LIT:0.0> <EOL> self . ewma = EWMA . fifteen_minute_EWMA ( ) <EOL> self . ewma . update ( <NUM_LIT:3> ) <EOL> time_mock . return_value += <NUM_LIT:5> <EOL> self . ewma . tick ( ) <EOL> for expected_rate in [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] : <EOL> self . assertAlmostEqual ( self . ewma . get_rate ( ) , expected_rate ) <EOL> self . elapse_minute ( time_mock ) <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_one_minute_EWMA_one_minute_tick ( self , time_mock ) : <EOL> time_mock . return_value = <NUM_LIT:0.0> <EOL> self . ewma = EWMA . one_minute_EWMA ( ) <EOL> self . ewma . update ( <NUM_LIT:3> ) <EOL> time_mock . return_value += <NUM_LIT:5> <EOL> self . ewma . tick ( ) <EOL> for expected_rate in [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] : <EOL> self . assertAlmostEqual ( self . ewma . get_rate ( ) , expected_rate ) <EOL> time_mock . return_value += <NUM_LIT> <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_five_minute_EWMA_one_minute_tick ( self , time_mock ) : <EOL> time_mock . return_value = <NUM_LIT:0.0> <EOL> self . ewma = EWMA . five_minute_EWMA ( ) <EOL> self . ewma . update ( <NUM_LIT:3> ) <EOL> time_mock . return_value += <NUM_LIT:5> <EOL> self . ewma . tick ( ) <EOL> for expected_rate in [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] : <EOL> self . assertAlmostEqual ( self . ewma . get_rate ( ) , expected_rate ) <EOL> time_mock . return_value += <NUM_LIT> <EOL> @ mock . patch ( "<STR_LIT>" ) <EOL> def test_fifteen_minute_EWMA_one_minute_tick ( self , time_mock ) : <EOL> time_mock . return_value = <NUM_LIT:0.0> <EOL> self . ewma = EWMA . fifteen_minute_EWMA ( ) <EOL> self . ewma . update ( <NUM_LIT:3> ) <EOL> time_mock . return_value += <NUM_LIT:5> <EOL> self . ewma . tick ( ) <EOL> for expected_rate in [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] : <EOL> self . assertAlmostEqual ( self . ewma . get_rate ( ) , expected_rate ) <EOL> time_mock . return_value += <NUM_LIT> </s>
