Esempio n. 1
0
def test_moving_average__empty():
    #It should be possible to initialize with an empty list
    ts = TimeSeries([])
    ts.moving_average(3)
    assert(ts.data==[])
Esempio n. 2
0
def test_moving_average__first_val():
    ts = TimeSeries(sample_data)
    original_len = len(ts.data)
    ts.moving_average(3)
    assert(ts.data[0][-1]==(200+50)/3)
Esempio n. 3
0
def test_moving_average__first_day(window):
    ts = TimeSeries(sample_data)
    ts.moving_average(window)
    assert(ts.data[0][0]==sample_data[0][0]+datetime.timedelta(window-1))
Esempio n. 4
0
def test_moving_average__last_day(window):
    ts = TimeSeries(sample_data)
    original_len = len(ts.data)
    ts.moving_average(window)
    assert(ts.data[-1][0]==sample_data[-1][0])
Esempio n. 5
0
def test_moving_average__len(window):
    ts = TimeSeries(sample_data)
    original_len = len(ts.data)
    ts.moving_average(window)
    assert(len(ts.data)==original_len-window+1)