def _is_dtype_compat(self, other):
if is_categorical_dtype(other):<EOL><INDENT>if isinstance(other, CategoricalIndex):<EOL><INDENT>other = other._values<EOL><DEDENT>if not other.is_dtype_equal(self):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>values = other<EOL>if not is_list_like(values):<EOL><INDENT>values = [values]<EOL><DEDENT>other = CategoricalIndex(self._create_categorical(<EOL>other, dtype=self.dtype))<EOL>if not other.isin(values).all():<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>return other<EOL>
*this is an internal non-public method*

provide a comparison between the dtype of self and other (coercing if
needed)

Raises
------
TypeError if the dtypes are not compatible