def assert_index_equal(left, right, exact='<STR_LIT>', check_names=True,<EOL>check_less_precise=False, check_exact=True,<EOL>check_categorical=True, obj='<STR_LIT>'):
__tracebackhide__ = True<EOL>def _check_types(l, r, obj='<STR_LIT>'):<EOL><INDENT>if exact:<EOL><INDENT>assert_class_equal(l, r, exact=exact, obj=obj)<EOL>if check_categorical:<EOL><INDENT>assert_attr_equal('<STR_LIT>', l, r, obj=obj)<EOL><DEDENT>if l.inferred_type in ('<STR_LIT:string>', '<STR_LIT>'):<EOL><INDENT>assert r.inferred_type in ('<STR_LIT:string>', '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>assert_attr_equal('<STR_LIT>', l, r, obj=obj)<EOL><DEDENT><DEDENT><DEDENT>def _get_ilevel_values(index, level):<EOL><INDENT>unique = index.levels[level]<EOL>labels = index.codes[level]<EOL>filled = take_1d(unique.values, labels, fill_value=unique._na_value)<EOL>values = unique._shallow_copy(filled, name=index.names[level])<EOL>return values<EOL><DEDENT>_check_isinstance(left, right, Index)<EOL>_check_types(left, right, obj=obj)<EOL>if left.nlevels != right.nlevels:<EOL><INDENT>msg1 = '<STR_LIT>'.format(obj=obj)<EOL>msg2 = '<STR_LIT>'.format(nlevels=left.nlevels, left=left)<EOL>msg3 = '<STR_LIT>'.format(nlevels=right.nlevels, right=right)<EOL>raise_assert_detail(obj, msg1, msg2, msg3)<EOL><DEDENT>if len(left) != len(right):<EOL><INDENT>msg1 = '<STR_LIT>'.format(obj=obj)<EOL>msg2 = '<STR_LIT>'.format(length=len(left), left=left)<EOL>msg3 = '<STR_LIT>'.format(length=len(right), right=right)<EOL>raise_assert_detail(obj, msg1, msg2, msg3)<EOL><DEDENT>if left.nlevels > <NUM_LIT:1>:<EOL><INDENT>for level in range(left.nlevels):<EOL><INDENT>llevel = _get_ilevel_values(left, level)<EOL>rlevel = _get_ilevel_values(right, level)<EOL>lobj = '<STR_LIT>'.format(level=level)<EOL>assert_index_equal(llevel, rlevel,<EOL>exact=exact, check_names=check_names,<EOL>check_less_precise=check_less_precise,<EOL>check_exact=check_exact, obj=lobj)<EOL>_check_types(left.levels[level], right.levels[level], obj=obj)<EOL><DEDENT><DEDENT>if check_exact and check_categorical:<EOL><INDENT>if not left.equals(right):<EOL><INDENT>diff = np.sum((left.values != right.values)<EOL>.astype(int)) * <NUM_LIT> / len(left)<EOL>msg = '<STR_LIT>'.format(<EOL>obj=obj, pct=np.round(diff, <NUM_LIT:5>))<EOL>raise_assert_detail(obj, msg, left, right)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>_testing.assert_almost_equal(left.values, right.values,<EOL>check_less_precise=check_less_precise,<EOL>check_dtype=exact,<EOL>obj=obj, lobj=left, robj=right)<EOL><DEDENT>if check_names:<EOL><INDENT>assert_attr_equal('<STR_LIT>', left, right, obj=obj)<EOL><DEDENT>if isinstance(left, pd.PeriodIndex) or isinstance(right, pd.PeriodIndex):<EOL><INDENT>assert_attr_equal('<STR_LIT>', left, right, obj=obj)<EOL><DEDENT>if (isinstance(left, pd.IntervalIndex) or<EOL>isinstance(right, pd.IntervalIndex)):<EOL><INDENT>assert_interval_array_equal(left.values, right.values)<EOL><DEDENT>if check_categorical:<EOL><INDENT>if is_categorical_dtype(left) or is_categorical_dtype(right):<EOL><INDENT>assert_categorical_equal(left.values, right.values,<EOL>obj='<STR_LIT>'.format(obj=obj))<EOL><DEDENT><DEDENT>
Check that left and right Index are equal.

    Parameters
    ----------
    left : Index
    right : Index
    exact : bool / string {'equiv'}, default 'equiv'
        Whether to check the Index class, dtype and inferred_type
        are identical. If 'equiv', then RangeIndex can be substituted for
        Int64Index as well.
    check_names : bool, default True
        Whether to check the names attribute.
    check_less_precise : bool or int, default False
        Specify comparison precision. Only used when check_exact is False.
        5 digits (False) or 3 digits (True) after decimal points are compared.
        If int, then specify the digits to compare
    check_exact : bool, default True
        Whether to compare number exactly.
    check_categorical : bool, default True
        Whether to compare internal Categorical exactly.
    obj : str, default 'Index'
        Specify object name being compared, internally used to show appropriate
        assertion message