def ensure_variables_in_data(data, variables):
    """Check data contains expected variables.

    Parameters
    ----------
    data : object
        Object supporting membership testing with the in operator,
        representing a dataset.

    variables : list
        List of variables to check for in data.

    Returns
    -------
    data : dict-like
        The input dataset.
    """

    if data is None:
        raise ValueError('No data given')

    for v in variables:
        if v not in data:
            raise ValueError(
                "Variable '%s' not present in given data." % v)

    return data