def test_update_sma(): points = Points(test_util.point_gen([1, 2, 3, 4, 5])) f = points.sma(2) assert f(4) == 4.5 assert f(5) is None assert len(f.accumulated_points._points) == 3 points.append((5, 6)) assert f(5) == 5.5 assert len(f.accumulated_points._points) == 4
def test_append_to_empty(): points = Points([]) sma = points.sma(2) points.append_list(test_util.point_gen([1, 2, 3, 4], t_start=10)) assert np.allclose(sma.sample_points(), [(11, 1.5), (12, 2.5), (13, 3.5)])
def test_replace(): points = Points(test_util.point_gen([1, 2, 3, 4])) f = points.sma(2) assert f(3) == 3.5 points.replace((3, 5)) assert f(3) == 4