ieml/distance/sort.py
def square_order_matrix(usl_list):
    """
    Compute the ordering of a list of usls from each usl and return the matrix m s.t.
    for each u in usl_list at index i, [usl_list[j] for j in m[i, :]] is the list sorted
    by proximity from u.
     of the result
    :param usl_list: a list of usls
    :return: a (len(usl_list), len(usl_list)) np.array

    """
    usl_list = list(usl_list)
    indexes = {
        u: i for i, u in enumerate(usl_list)
    }

    order_mat = np.zeros(shape=(len(usl_list), len(usl_list)), dtype=int)

    for u in usl_list:
        sorted_list = QuerySort(u).sort(collection=usl_list)
        for i, u_s in enumerate(sorted_list):
            order_mat[indexes[u], indexes[u_s]] = i

    return order_mat
def square_order_matrix(usl_list):
    """
    Compute the ordering of a list of usls from each usl and return the matrix m s.t.
    for each u in usl_list at index i, [usl_list[j] for j in m[i, :]] is the list sorted
    by proximity from u.
     of the result
    :param usl_list: a list of usls
    :return: a (len(usl_list), len(usl_list)) np.array

    """
    usl_list = list(usl_list)
    indexes = {
        u: i for i, u in enumerate(usl_list)
    }

    order_mat = np.zeros(shape=(len(usl_list), len(usl_list)), dtype=int)

    for u in usl_list:
        sorted_list = QuerySort(u).sort(collection=usl_list)
        for i, u_s in enumerate(sorted_list):
            order_mat[indexes[u], indexes[u_s]] = i

    return order_mat
Compute the ordering of a list of usls from each usl and return the matrix m s.t.
    for each u in usl_list at index i, [usl_list[j] for j in m[i, :]] is the list sorted
    by proximity from u.
     of the result
    :param usl_list: a list of usls
    :return: a (len(usl_list), len(usl_list)) np.array