def _check_compensation_grade(info1, info2, name1, name2='data', ch_names=None
    ):
    """Ensure that objects have same compensation_grade."""
    from ..io import Info
    from ..io.pick import pick_channels, pick_info
    from ..io.compensator import get_current_comp
    for t_info in (info1, info2):
        if t_info is None:
            return
        assert isinstance(t_info, Info), t_info
    if ch_names is not None:
        info1 = info1.copy()
        info2 = info2.copy()
        for t_info in [info1, info2]:
            if t_info['comps']:
                t_info['comps'] = []
            picks = pick_channels(t_info['ch_names'], ch_names)
            pick_info(t_info, picks, copy=False)
    grade1 = get_current_comp(info1) or 0
    grade2 = get_current_comp(info2) or 0
    if grade1 != grade2:
        raise RuntimeError(
            'Compensation grade of %s (%s) and %s (%s) do not match' % (
            name1, grade1, name2, grade2))
