MCPcopy Create free account
hub / github.com/PythonOT/POT / unvectorized

Function unvectorized

test/test_da.py:1028–1039  ·  view source on GitHub ↗
(transp)

Source from the content-addressed store, hash-verified

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)

Callers 1

Calls 4

uniqueMethod · 0.45
whereMethod · 0.45
onesMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected