def sets_to_clusters(sets, idx_to_name):
    """
    Converts a set representation of a partition to a vector of object labels.
    """

    assert len(idx_to_name) == sum([len(a) for a in sets])
    
    arr = []
    for i in range(len(idx_to_name)):
        name = idx_to_name[i]
        cl = [j for j in range(len(sets)) if name in sets[j]]
        assert len(cl) == 1
        cl = cl[0]
        arr.append(cl)
        
    return arr