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)
    )
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)
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
Beispiel #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}"
Beispiel #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
def test_cathetus_exact(h, a, b):
    assert cathetus(h, a) == b
def test_cathetus_signs(h, a, b):
    assert abs(cathetus(h, a) - b) <= abs(b) * float_info.epsilon
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
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_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))
def test_cathetus_infinite(h, a):
    assert math.isinf(cathetus(h, a))
def test_cathetus_infinite(h, a):
    assert math.isinf(cathetus(h, a))
def test_cathetus_always_leq_hypot(h, a):
    assume(h >= a)
    b = cathetus(h, a)
    assert 0 <= b <= h
def test_pythagorean_triples(a, b, h):
    assert math.hypot(a, b) == h, 'defective pythagoran triple'
    assert cathetus(h, a) == b