def remove_incompatible_items(first_dict, second_dict, compat=equivalent):
    """Remove incompatible items from the first dictionary in-place.

    Items are retained if their keys are found in both dictionaries and the
    values are compatible.

    Parameters
    ----------
    first_dict, second_dict : dict-like
        Mappings to merge.
    compat : function, optional
        Binary operator to determine if two values are compatible. By default,
        checks for equivalence.
    """
    for k in list(first_dict):
        if (k not in second_dict or
            (second_dict in k and
                not compat(first_dict[k], second_dict[k]))):
            del first_dict[k]
dataset/ETHPy150Open pydata/xarray/xarray/core/utils.py/remove_incompatible_items/swapped operands of `in`