#NEWLINE# @ staticmethod #NEWLINE# def abs_rel_err( a , b ) : #NEWLINE# #INDENT# 'Return absolute and relative error between a and b.\n\n        The relative error is a small number when a and b are close, relative\n        to how big they are.\n\n        Formulas used:\n            abs_err = abs(a - b)\n            rel_err = abs_err / max(abs(a) + abs(b), 1e-8)\n\n        The denominator is clipped at 1e-8 to avoid dividing by 0 when a and b\n        are both close to 0.\n\n        The tuple (abs_err, rel_err) is returned\n        ' #NEWLINE# abs_err = abs ( ( a - b ) ) #NEWLINE# rel_err = ( abs_err / numpy . maximum ( ( abs ( a ) + abs ( b ) ) , 1e-08 ) ) #NEWLINE# abs_err = numpy . asarray ( abs_err ) #NEWLINE# rel_err = numpy . asarray ( rel_err ) #NEWLINE# return ( abs_err , rel_err )