示例#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==[])
示例#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)
示例#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))
示例#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])
示例#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)