Check whether two arrays have compatible dtypes to do a union.
    numpy types are checked with ``is_dtype_equal``. Extension types are
    checked separately.

    Parameters
    ----------
    source : The first dtype to compare
    target : The second dtype to compare

    Returns
    ----------
    boolean
        Whether or not the two dtypes are equal.

    >>> is_dtype_equal("int", int)
    True

    >>> is_dtype_equal(CategoricalDtype(['a', 'b'],
    ...                CategoricalDtype(['b', 'c']))
    True

    >>> is_dtype_equal(CategoricalDtype(['a', 'b'],
    ...                CategoricalDtype(['b', 'c'], ordered=True))
    False

def is_dtype_union_equal(source, target):
    """
    Check whether two arrays have compatible dtypes to do a union.
    numpy types are checked with ``is_dtype_equal``. Extension types are
    checked separately.

    Parameters
    ----------
    source : The first dtype to compare
    target : The second dtype to compare

    Returns
    ----------
    boolean
        Whether or not the two dtypes are equal.

    >>> is_dtype_equal("int", int)
    True

    >>> is_dtype_equal(CategoricalDtype(['a', 'b'],
    ...                CategoricalDtype(['b', 'c']))
    True

    >>> is_dtype_equal(CategoricalDtype(['a', 'b'],
    ...                CategoricalDtype(['b', 'c'], ordered=True))
    False
    """
    source = _get_dtype(source)
    target = _get_dtype(target)
    if is_categorical_dtype(source) and is_categorical_dtype(target):
        # ordered False for both
        return source.ordered is target.ordered
    return is_dtype_equal(source, target)