def comparefloats(a, b):
 aa = a
 bb = b
 if ((aa.dtype.name == 'float32') or (bb.dtype.name == 'float32')):
  precision = 1e-06
 else:
  precision = 1e-16
 precision = 1e-05
 diff = np.absolute((aa - bb))
 mask0 = (aa == 0)
 masknz = (aa != 0.0)
 if np.any(mask0):
  if (diff[mask0].max() != 0.0):
   return False
 if np.any(masknz):
  if ((diff[masknz] / np.absolute(aa[masknz])).max() > precision):
   return False
 return True

def comparefloats ( a , b ) : aa = a bb = b if ( ( aa . dtype . name == 'float32' ) or ( bb . dtype . name == 'float32' ) ) : precision = 1e-06 else : precision = 1e-16 precision = 1e-05 diff = np . absolute ( ( aa - bb ) ) mask0 = ( aa == 0 ) masknz = ( aa != 0.0 ) if np . any ( mask0 ) : if ( diff [ mask0 ] . max ( ) != 0.0 ) : return False if np . any ( masknz ) : if ( ( diff [ masknz ] / np . absolute ( aa [ masknz ] ) ) . max ( ) > precision ) : return False return True
compare two float scalars or arrays and see if they are consistent consistency is determined ensuring the difference is less than the expected amount .