def ulp_abs_check(expected, got, ulp_tol, abs_tol):
 ulp_error = abs((to_ulps(expected) - to_ulps(got)))
 abs_error = abs((expected - got))
 if ((abs_error <= abs_tol) or (ulp_error <= ulp_tol)):
  return None
 else:
  fmt = 'error = {:.3g} ({:d} ulps); permitted error = {:.3g} or {:d} ulps'
  return fmt.format(abs_error, ulp_error, abs_tol, ulp_tol)

def ulp_abs_check ( expected , got , ulp_tol , abs_tol ) : ulp_error = abs ( ( to_ulps ( expected ) - to_ulps ( got ) ) ) abs_error = abs ( ( expected - got ) ) if ( ( abs_error <= abs_tol ) or ( ulp_error <= ulp_tol ) ) : return None else : fmt = 'error = {:.3g} ({:d} ulps); permitted error = {:.3g} or {:d} ulps' return fmt . format ( abs_error , ulp_error , abs_tol , ulp_tol )
given finite floats expected and got .