def ensure_all_wide_alt_ids_are_chosen(choice_col,
                                       alt_specific_vars,
                                       availability_vars,
                                       wide_data):
    """
    Checks to make sure all user-specified alternative id's, both in
    `alt_specific_vars` and `availability_vars` are observed in the choice
    column of `wide_data`.
    """
    sorted_alt_ids = np.sort(wide_data[choice_col].unique())
    try:
        problem_ids = [x for x in availability_vars
                       if x not in sorted_alt_ids]
        problem_type = "availability_vars"
        assert problem_ids == []

        problem_ids = []
        for new_column in alt_specific_vars:
            for alt_id in alt_specific_vars[new_column]:
                if alt_id not in sorted_alt_ids and alt_id not in problem_ids:
                    problem_ids.append(alt_id)
        problem_type = "alt_specific_vars"
        assert problem_ids == []
    except AssertionError:
        msg = "The following alternative ids from {} are not "
        msg_2 = "observed in wide_data[choice_col]:\n{}"
        raise ValueError(msg.format(problem_type) + msg_2.format(problem_ids))

    return None
def ensure_all_wide_alt_ids_are_chosen ( choice_col , alt_specific_vars , availability_vars , wide_data ) : sorted_alt_ids = np . sort ( wide_data [ choice_col ] . unique ( ) ) try : problem_ids = [ x for x in availability_vars if x not in sorted_alt_ids ] problem_type = "availability_vars" assert problem_ids == [ ] problem_ids = [ ] for new_column in alt_specific_vars : for alt_id in alt_specific_vars [ new_column ] : if alt_id not in sorted_alt_ids and alt_id not in problem_ids : problem_ids . append ( alt_id ) problem_type = "alt_specific_vars" assert problem_ids == [ ] except AssertionError : msg = "The following alternative ids from {} are not " msg_2 = "observed in wide_data[choice_col]:\n{}" raise ValueError ( msg . format ( problem_type ) + msg_2 . format ( problem_ids ) ) return None
Checks to make sure all user-specified alternative id's, both in
    `alt_specific_vars` and `availability_vars` are observed in the choice
    column of `wide_data`.