def test_square_within_tolerance_out(ffmt): D.set_float_fmt(ffmt) pi = D.to_float(D.pi) out = D.copy(pi) D.square(pi, out=out) assert (9.8696044010893586188 - 2 * D.epsilon() <= out <= 9.8696044010893586188 + 2 * D.epsilon())
def test_softplus_within_tolerance_out(ffmt): D.set_float_fmt(ffmt) pi = D.to_float(D.pi) out = D.copy(pi) D.softplus(pi, out=out) assert (3.18389890758499587775 - 2 * D.epsilon() <= out <= 3.18389890758499587775 + 2 * D.epsilon())
def test_addcmul_within_tolerance_out(ffmt): D.set_float_fmt(ffmt) pi = D.to_float(D.pi) out = D.copy(pi) D.addcmul(pi, D.to_float(3), D.to_float(2), value=1, out=out) assert (pi + (1 * (3 * 2)) - 2 * D.epsilon() <= out <= pi + (1 * (3 * 2)) + 2 * D.epsilon())
def test_frac_within_tolerance_out(ffmt): D.set_float_fmt(ffmt) pi = D.to_float(D.pi) out = D.copy(pi) D.frac(pi, out=out) assert (0.141592653589793238 - 2 * D.epsilon() <= out <= 0.141592653589793238 + 2 * D.epsilon())
def test_lerp_within_tolerance_out(ffmt): D.set_float_fmt(ffmt) pi = D.to_float(D.pi) out = D.copy(pi) D.lerp(pi, pi + 1, 0.5, out=out) assert (pi + 0.5 - 2 * D.epsilon() <= out <= pi + 0.5 + 2 * D.epsilon())