def ensure_each_wide_obs_chose_an_available_alternative(obs_id_col,
    choice_col, availability_vars, wide_data):
    """
    Checks whether or not each observation with a restricted choice set chose
    an alternative that was personally available to him or her. Will raise a
    helpful ValueError if this is not the case.

    Parameters
    ----------
    obs_id_col : str.
        Denotes the column in `wide_data` that contains the observation ID
        values for each row.
    choice_col : str.
        Denotes the column in `wide_data` that contains a one if the
        alternative pertaining to the given row was the observed outcome for
        the observation pertaining to the given row and a zero otherwise.
    availability_vars : dict.
        There should be one key value pair for each alternative that is
        observed in the dataset. Each key should be the alternative id for the
        alternative, and the value should be the column heading in `wide_data`
        that denotes (using ones and zeros) whether an alternative is
        available/unavailable, respectively, for a given observation.
        Alternative id's, i.e. the keys, must be integers.
    wide_data : pandas dataframe.
        Contains one row for each observation. Should have the specified
        `[obs_id_col, choice_col] + availability_vars.values()` columns.

    Returns
    -------
    None
    """
    wide_availability_values = wide_data[list(availability_vars.values())
        ].values
    unavailable_condition = (wide_availability_values == 0).sum(axis=1).astype(
        bool)
    problem_obs = []
    for idx, row in wide_data.loc[unavailable_condition].iterrows():
        if row.at[availability_vars[row.at[choice_col]]] != 1:
            problem_obs.append(row.at[obs_id_col])
    if problem_obs != []:
        msg = 'The following observations chose unavailable alternatives:\n{}'
        raise ValueError(msg.format(problem_obs))
    return None
