'Fail if the two floating-point numbers are not almost equal.
Determine whether floating-point values a and b are equal to within
a (small) rounding error.  The default values for rel_err and
abs_err are chosen to be suitable for platforms where a float is
represented by an IEEE 754 double.  They allow an error of between
9 and 19 ulps.'

def rAssertAlmostEqual(self, a, b, rel_err=2e-15, abs_err=5e-323, msg=None):

    if math.isnan(a):
        if math.isnan(b):
            return
        self.fail((msg or '{!r}    should    be    nan'.format(b)))
    if math.isinf(a):
        if (a == b):
            return
        self.fail((msg or 'finite    result    where    infinity    expected:    expected    {!r},    got    {!r}'.format(a, b)))
    if ((not a) and (not b)):
        if (math.copysign(1.0, a) != math.copysign(1.0, b)):
            self.fail((msg or 'zero    has    wrong    sign:    expected    {!r},    got    {!r}'.format(a, b)))
    try:
        absolute_error = abs((b - a))
    except OverflowError:
        pass
    else:
        if (absolute_error <= max(abs_err, (rel_err * abs(a)))):
            return
    self.fail((msg or '{!r}    and    {!r}    are    not    sufficiently    close'.format(a, b)))
