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

Function df2

test/test_da.py:1005–1009  ·  view source on GitHub ↗
(G)

Source from the content-addressed store, hash-verified

1003 return nx.sum(nx.norm(G_split * unroll_labels_idx, axis=1))
1004
1005 def df2(G):
1006 G_split = nx.repeat(G.T[:, :, None], n_labels, axis=2) * unroll_labels_idx
1007 W = nx.norm(G_split * unroll_labels_idx, axis=1, keepdims=True)
1008 G_norm = G_split / nx.clip(W, 1e-12, None)
1009 return nx.sum(G_norm, axis=2).T
1010
1011 assert np.allclose(f(G), f2(G))
1012 assert np.allclose(df(G), df2(G))

Callers 1

Calls 4

repeatMethod · 0.45
normMethod · 0.45
clipMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected