示例#1
0
def test_paper_fig3():
    a = AInterval(-3.0, 2.0, eps_idx=1)
    b = AInterval(4.0, 8.0, eps_idx=2)
    c = 4.3
    d = a * b
    e = d + c
    z = e - b

    assert d.to_interval() == Interval(-24.0, 18.0)
    assert e.to_interval() == Interval(-19.7, 22.3)
    assert z.to_interval() == Interval(-25.7, 16.3)
示例#2
0
def test_to_string():
    #Two different wyas to construct an AInterval

    eps_idx = 1
    lo, hi = 0.0, 6.0
    x = AInterval(lo, hi, eps_idx=eps_idx)
    assert str(x) == "3.0 + 3.0*eps1"

    base = 3.0
    noise = {eps_idx: 3.0}
    x = AInterval(3.0, {1: 3.0})
    assert str(x) == "3.0 + 3.0*eps1"

    #AInterval can be converted to an I interval
    assert x.to_interval() == Interval(0.0, 6.0)
示例#3
0
def test_self_sub():
    x = Interval(-5, 5)
    z = x - x
    assert z == Interval(-10, 10)
示例#4
0
def test_mul_const():
    x = Interval(0, 5)
    y = 10
    z = x * y
    print(z)
    assert z == Interval(0, 50)
示例#5
0
def test_sub_const():
    x = Interval(0, 5)
    y = 10
    z = x - y
    print(z)
    assert z == Interval(-10, -5)
示例#6
0
def test_add():
    x = Interval(0, 5)
    y = Interval(3, 8)
    z = x + y
    print(z)
    assert z == Interval(3, 13)
示例#7
0
def test_add_const():
    x = Interval(0, 5)
    y = 10
    z = x + y
    print(z)
    assert z == Interval(10, 15)
示例#8
0
def test_mul():
    x = Interval(-2, 5)
    y = Interval(3, 8)
    z = x * y
    print(z)
    assert z == Interval(-16, 40)
示例#9
0
def test_sub():
    x = Interval(0, 5)
    y = Interval(3, 8)
    z = x - y
    print(z)
    assert z == Interval(-8, 2)