(groups: List)
return output, unique_group_names
Generate matrix which notes factor membership of groups

    Computes a k-by-g matrix which notes factor membership of groups
    where:
        k is the number of variables (factors)
        g is the number of groups
    Also returns a g-length list of unique group_names whose positions
    correspond to the order of groups in the k-by-g matrix

    Parameters
    ----------
    groups : List
        Group names corresponding to each variable

    Returns
    -------
    tuple
        containing group matrix assigning parameters to
        groups and a list of unique group names
Generate matrix which notes factor membership of groups
Generate matrix which notes factor membership of groups
def compute_groups_matrix(groups: List):
    """Generate matrix which notes factor membership of groups

    Computes a k-by-g matrix which notes factor membership of groups
    where:
        k is the number of variables (factors)
        g is the number of groups
    Also returns a g-length list of unique group_names whose positions
    correspond to the order of groups in the k-by-g matrix

    Parameters
    ----------
    groups : List
        Group names corresponding to each variable

    Returns
    -------
    tuple
        containing group matrix assigning parameters to
        groups and a list of unique group names
    """
    num_vars = len(groups)
    unique_group_names, number_of_groups = extract_group_names(groups)

    indices = dict([(x, i) for (i, x) in enumerate(unique_group_names)])

    output = np.zeros((num_vars, number_of_groups), dtype=int)

    for parameter_row, group_membership in enumerate(groups):
        group_index = indices[group_membership]
        output[parameter_row, group_index] = 1

    return output, unique_group_names
def compute_groups_matrix ( groups : List ) : num_vars = len ( groups ) unique_group_names , number_of_groups = extract_group_names ( groups ) indices = dict ( [ ( x , i ) for ( i , x ) in enumerate ( unique_group_names ) ] ) output = np . zeros ( ( num_vars , number_of_groups ) , dtype = int ) for parameter_row , group_membership in enumerate ( groups ) : group_index = indices [ group_membership ] output [ parameter_row , group_index ] = 1 return output , unique_group_names