示例#1
0
def test_max():
    f = Curve.max([Points([(0, -1), (1, 0), (2, 1)]), 0])
    assert f.domain == Interval.closed(0, 2)
    assert f.y(-1) is None
    assert f.y(0) == 0
    assert f.y(1) == 0
    assert f.y(2) == 1
    assert f.y(3) is None

    f = Curve.max([0, Points([(0, -1), (1, 0), (2, 1)])])
    assert f.domain == Interval.closed(0, 2)
    assert f.y(-1) is None
    assert f.y(0) == 0
    assert f.y(1) == 0
    assert f.y(2) == 1
    assert f.y(3) is None
示例#2
0
def test_min_max():
    funcs = [2, Line(const=0, slope=1)]
    minf = Curve.min(funcs)
    maxf = Curve.max(funcs)

    assert minf(0) == 0
    assert minf(1) == 1
    assert minf(2) == 2
    assert minf(3) == 2
    assert minf(4) == 2

    assert maxf(0) == 2
    assert maxf(1) == 2
    assert maxf(2) == 2
    assert maxf(3) == 3
    assert maxf(4) == 4