Skip to content

Instantly share code, notes, and snippets.

@pjz
Last active June 16, 2016 20:17
Show Gist options
  • Save pjz/ca9c384edce1e45f74c2ec2ab440c50d to your computer and use it in GitHub Desktop.
Save pjz/ca9c384edce1e45f74c2ec2ab440c50d to your computer and use it in GitHub Desktop.
def test_ma_short_skips():
ma = MovingAverage([1,2,5,10])
for i in range(11):
ma.update(i, 5)
assert ma.cur == [ 5, 5, 5, 5 ]
ma = MovingAverage([1,2,3])
for t, v in enumerate([2, 4, 6, 8]):
ma.update(t, v)
assert ma.cur == [7, 6, 5]
def test_ma_long_skips():
ma = MovingAverage([1,2,5,10])
ma.update(0, 6)
ma.update(20, 6)
assert ma.cur == [ 6, 6, 6, 6 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment