Exemplo n.º 1
0
def test_cathetus_large_no_overflow():
    h = sys.float_info.max / 3
    a = h / math.sqrt(2)
    b = cathetus(h, a)
    assert not (math.isinf(b) or math.isnan(b)), (
        'expecting finite cathetus(%g, %g), got %g' % (h, a, b)
    )
Exemplo n.º 2
0
def test_cathetus_simple_underflow():
    a = sys.float_info.min
    h = a * math.sqrt(2)
    b = cathetus(h, a)
    assert b > 0, (
        'expecting positive cathetus(%g, %g), got %g' % (h, a, b)
    )
def test_cathetus_large_no_overflow():
    h = sys.float_info.max / 3
    a = h / math.sqrt(2)
    b = cathetus(h, a)
    assert not (
        math.isinf(b) or math.isnan(b)
    ), "expecting finite cathetus(%g, %g), got %g" % (h, a, b)
Exemplo n.º 4
0
def test_pythagorean_triples(a, b, h):
    assert abs(math.hypot(a, b) - h) <= abs(h) * float_info.epsilon
    assert abs(cathetus(h, a) - b) <= abs(b) * float_info.epsilon
Exemplo n.º 5
0
def test_cathetus_large_no_overflow():
    h = sys.float_info.max / 3
    a = h / math.sqrt(2)
    b = cathetus(h, a)
    assert math.isfinite(
        b), f"expecting finite cathetus({h:g}, {a:g}), got {b:g}"
Exemplo n.º 6
0
def test_cathetus_simple_underflow():
    a = sys.float_info.min
    h = a * math.sqrt(2)
    b = cathetus(h, a)
    assert b > 0, f"expecting positive cathetus({h:g}, {a:g}), got {b:g}"
def test_cathetus_signs(h, a, b):
    assert abs(cathetus(h, a) - b) <= abs(b) * float_info.epsilon
Exemplo n.º 8
0
def test_cathetus_exact(h, a, b):
    assert cathetus(h, a) == b
Exemplo n.º 9
0
def test_cathetus_signs(h, a, b):
    assert abs(cathetus(h, a) - b) <= abs(b) * float_info.epsilon
Exemplo n.º 10
0
def test_cathetus_nan(h, a):
    assert math.isnan(cathetus(h, a))
def test_cathetus_simple_underflow():
    a = sys.float_info.min
    h = a * math.sqrt(2)
    b = cathetus(h, a)
    assert b > 0, "expecting positive cathetus(%g, %g), got %g" % (h, a, b)
def test_cathetus_subnormal_underflow():
    u = sys.float_info.min * sys.float_info.epsilon
    h = 5 * u
    a = 4 * u
    assert cathetus(h, a) == 3 * u
def test_pythagorean_triples(a, b, h):
    assert abs(math.hypot(a, b) - h) <= abs(h) * float_info.epsilon
    assert abs(cathetus(h, a) - b) <= abs(b) * float_info.epsilon
def test_cathetus_always_leq_hypot(h, a):
    assume(h >= a)
    b = cathetus(h, a)
    assert 0 <= b <= h
Exemplo n.º 15
0
def test_cathetus_subnormal_underflow():
    u = sys.float_info.min * sys.float_info.epsilon
    h = 5 * u
    a = 4 * u
    assert cathetus(h, a) == 3 * u
Exemplo n.º 16
0
def test_cathetus_large_no_overflow():
    h = sys.float_info.max / 3
    a = h / math.sqrt(2)
    b = cathetus(h, a)
    assert math.isfinite(b), "expecting finite cathetus(%g, %g), got %g" % (h, a, b)
def test_cathetus_nan(h, a):
    assert math.isnan(cathetus(h, a))
Exemplo n.º 18
0
def test_cathetus_infinite(h, a):
    assert math.isinf(cathetus(h, a))
def test_cathetus_infinite(h, a):
    assert math.isinf(cathetus(h, a))
Exemplo n.º 20
0
def test_cathetus_always_leq_hypot(h, a):
    assume(h >= a)
    b = cathetus(h, a)
    assert 0 <= b <= h
Exemplo n.º 21
0
def test_pythagorean_triples(a, b, h):
    assert math.hypot(a, b) == h, 'defective pythagoran triple'
    assert cathetus(h, a) == b