Beispiel #1
0
def test_replace():
    points = Points([(0, 1), (1, 2)], uniform=False)
    assert points(1) == 2
    points.replace((1, 3))
    assert points(1) == 3

    points = Points([(0, 1), (1, 2)], uniform=False)
    assert points(0.5) == 1.5
    points.replace((0.5, 3))
    assert points(0.5) == 3

    points = Points([(0, 1), (1, 2)], uniform=True)
    with pytest.raises(Exception):
        points.replace((0.5, 3))

    points = Points([(0, 1), (1, 2)], uniform=False)
    assert points(2) is None
    with pytest.raises(Exception):
        points.replace((2, 3), or_append=False)
    points.replace((2, 3), or_append=True)
    assert points(2) == 3
Beispiel #2
0
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