def comparerecords(a, b):

    nfieldsa = len(a.dtype.names)
    nfieldsb = len(b.dtype.names)
    if nfieldsa != nfieldsb:
        print_("number of fields don't match")
        return False
    for i in range(nfieldsa):
        fielda = a.field(i)
        fieldb = b.field(i)
        if fielda.dtype.char == 'S':
            fielda = decode_ascii(fielda)
        if fieldb.dtype.char == 'S':
            fieldb = decode_ascii(fieldb)
        if (type(fielda) != type(fieldb) and not
            (issubclass(type(fielda), type(fieldb)) or
             issubclass(type(fieldb), type(fielda)))):
            print_("type(fielda): ", type(fielda), " fielda: ", fielda)
            print_("type(fieldb): ", type(fieldb), " fieldb: ", fieldb)
            print_('field %d type differs' % i)
            return False
        if len(fielda) and isinstance(fielda[0], np.floating):
            if not comparefloats(fielda, fieldb):
                print_("fielda: ", fielda)
                print_("fieldb: ", fieldb)
                print_('field %d differs' % i)
                return False
        elif (isinstance(fielda, fits.column._VLF) or
              isinstance(fieldb, fits.column._VLF)):
            for row in range(len(fielda)):
                if np.any(fielda[row] != fieldb[row]):
                    print_('fielda[%d]: %s' % (row, fielda[row]))
                    print_('fieldb[%d]: %s' % (row, fieldb[row]))
                    print_('field %d differs in row %d' % (i, row))
        else:
            if np.any(fielda != fieldb):
                print_("fielda: ", fielda)
                print_("fieldb: ", fieldb)
                print_('field %d differs' % i)
                return False
    return True
Compare two record arrays
dataset/ETHPy150Open spacetelescope/PyFITS/pyfits/tests/test_table.py/comparerecords