def _raise_on_incompatible(left, right):
    """
    Helper function to render a consistent error message when raising
    IncompatibleFrequency.

    Parameters
    ----------
    left : PeriodArray
    right : DateOffset, Period, ndarray, or timedelta-like

    Raises
    ------
    IncompatibleFrequency
    """
    # GH#24283 error message format depends on whether right is scalar
    if isinstance(right, np.ndarray):
        other_freq = None
    elif isinstance(right, (ABCPeriodIndex, PeriodArray, Period, DateOffset)):
        other_freq = right.freqstr
    else:
        other_freq = _delta_to_tick(Timedelta(right)).freqstr

    msg = DIFFERENT_FREQ.format(cls=type(left).__name__,
                                own_freq=left.freqstr,
                                other_freq=other_freq)
    raise IncompatibleFrequency(msg)
Helper function to render a consistent error message when raising
    IncompatibleFrequency.

    Parameters
    ----------
    left : PeriodArray
    right : DateOffset, Period, ndarray, or timedelta-like

    Raises
    ------
    IncompatibleFrequency