(transp)
| 1026 | T = nx.from_numpy(rng.rand(n_samples, n_samples)) |
| 1027 | |
| 1028 | def unvectorized(transp): |
| 1029 | indices_labels = [] |
| 1030 | classes = nx.unique(labels_a) |
| 1031 | for c in classes: |
| 1032 | (idxc,) = nx.where(labels_a == c) |
| 1033 | indices_labels.append(idxc) |
| 1034 | W = nx.ones(M.shape, type_as=M) |
| 1035 | for i, c in enumerate(classes): |
| 1036 | majs = nx.sum(transp[indices_labels[i]], axis=0) |
| 1037 | majs = p * ((majs + epsilon) ** (p - 1)) |
| 1038 | W[indices_labels[i]] = majs |
| 1039 | return W |
| 1040 | |
| 1041 | def vectorized(transp): |
| 1042 | labels_u, labels_idx = nx.unique(labels_a, return_inverse=True) |
no test coverage detected