def assert_categorical_equal(left, right, check_dtype=True,<EOL>check_category_order=True, obj='<STR_LIT>'):
_check_isinstance(left, right, Categorical)<EOL>if check_category_order:<EOL><INDENT>assert_index_equal(left.categories, right.categories,<EOL>obj='<STR_LIT>'.format(obj=obj))<EOL>assert_numpy_array_equal(left.codes, right.codes,<EOL>check_dtype=check_dtype,<EOL>obj='<STR_LIT>'.format(obj=obj))<EOL><DEDENT>else:<EOL><INDENT>assert_index_equal(left.categories.sort_values(),<EOL>right.categories.sort_values(),<EOL>obj='<STR_LIT>'.format(obj=obj))<EOL>assert_index_equal(left.categories.take(left.codes),<EOL>right.categories.take(right.codes),<EOL>obj='<STR_LIT>'.format(obj=obj))<EOL><DEDENT>assert_attr_equal('<STR_LIT>', left, right, obj=obj)<EOL>
Test that Categoricals are equivalent.

    Parameters
    ----------
    left : Categorical
    right : Categorical
    check_dtype : bool, default True
        Check that integer dtype of the codes are the same
    check_category_order : bool, default True
        Whether the order of the categories should be compared, which
        implies identical integer codes.  If False, only the resulting
        values are compared.  The ordered attribute is
        checked regardless.
    obj : str, default 'Categorical'
        Specify object name being compared, internally used to show appropriate
        assertion message