def check_unit_compatibility(spec, region):
    """
    Checks if the unit of a region is compatible with the unit of the spectral
    axis of the spectrum object.

    Parameters
    ----------
    spec : :class:`specutils.Spectrum1D`
        The spectrum object with which to check compatibility.
    region : :class:`specutils.SpectralRegion`
        The region object with which to check compatibility.

    Returns
    -------
    bool
        Whether or not units are compatible.
    """
    spec_unit = spec.spectral_axis.unit
    if region.lower is not None:
        region_unit = region.lower.unit
    elif region.upper is not None:
        region_unit = region.upper.unit
    else:
        return False
    return spec_unit.is_equivalent(region_unit)