'Alternative to the built-in check_output that also handles parsing
float values and comparing their numeric values rather than their
string representations.
This requires rewriting enough of the basic check_output that, when
FLOAT_CMP is enabled, it totally takes over for check_output.'

def normalize_floats(self, want, got, flags):

    if (got == want):
        return True
    matches = self.num_got_rgx.finditer(got)
    numbers_got = [match.group(1) for match in matches]
    matches = self.num_want_rgx.finditer(want)
    numbers_want = [match.group(1) for match in matches]
    if (len(numbers_got) != len(numbers_want)):
        return False
    if (len(numbers_got) > 0):
        nw_ = []
        for (ng, nw) in zip(numbers_got, numbers_want):
            if (u'...' in nw):
                nw_.append(ng)
                continue
            else:
                nw_.append(nw)
            if (not np.allclose(float(ng), float(nw))):
                return False
        got = self.num_got_rgx.sub(u'{}', got)
        got = got.format(*tuple(nw_))
    if (not (flags & doctest.DONT_ACCEPT_BLANKLINE)):
        want = re.sub(u'(?m)^{}\\s*?$'.format(re.escape(doctest.BLANKLINE_MARKER)), u'', want)
        got = re.sub(u'(?m)^\\s*?$', u'', got)
        if (got == want):
            return True
    if (flags & doctest.NORMALIZE_WHITESPACE):
        got = u'    '.join(got.split())
        want = u'    '.join(want.split())
        if (got == want):
            return True
    if (flags & doctest.ELLIPSIS):
        if doctest._ellipsis_match(want, got):
            return True
    return False
