def cop(data, dist, labels):
    clusters = set(labels)
    cpairs = _get_clust_pairs(clusters)
    prox_lst = [dist[np.ix_((labels == i[0]), (labels == i[1]))].max() for i in cpairs]
    out_l = []
    for c in clusters:
        c_data = data[(labels == c)]
        c_center = c_data.mean(axis=0, keepdims=True)
        c_intra = pairwise_distances(c_data, c_center).mean()
        c_prox = [prox for (pair, prox) in zip(cpairs, prox_lst) if (c in pair)]
        c_inter = min(c_prox)
        to_add = ((len(c_data) * c_intra) / c_inter)
        out_l.append(to_add)
    return (sum(out_l) / len(labels))
def cop(data, dist, labels):
    clusters = set(labels)
    cpairs = _get_clust_pairs(clusters)
    prox_lst = [dist[np.ix_((labels == i[0]), (labels == i[1]))].max() for i in cpairs]
    out_l = []
    for c in clusters:
        c_data = data[(labels == c)]
        c_center = c_data.mean(axis=0, keepdims=True)
        c_intra = pairwise_distances(c_data, c_center).mean()
        c_prox = [prox for (pair, prox) in zip(cpairs, prox_lst) if (c in pair)]
        c_inter = min(c_prox)
        to_add = ((len(c_data) * c_intra) / c_inter)
        out_l.append(to_add)
    return (sum(out_l) / len(labels))