def tolerant_equals(a, b, atol=1e-06, rtol=1e-06, equal_nan=False):
 if (equal_nan and isnan(a) and isnan(b)):
  return True
 return (math.fabs((a - b)) <= (atol + (rtol * math.fabs(b))))

def tolerant_equals ( a , b , atol = 1e-06 , rtol = 1e-06 , equal_nan = False ) : if ( equal_nan and isnan ( a ) and isnan ( b ) ) : return True return ( math . fabs ( ( a - b ) ) <= ( atol + ( rtol * math . fabs ( b ) ) ) )
check if a and b are equal with some tolerance .