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

Function test_proj_SDP

test/test_utils.py:668–681  ·  view source on GitHub ↗
(nx)

Source from the content-addressed store, hash-verified

666
667
668def test_proj_SDP(nx):
669 t = np.pi / 8
670 U = np.array([[np.cos(t), -np.sin(t)], [np.sin(t), np.cos(t)]])
671 w = np.array([1.0, -1.0])
672 S = np.stack([U @ np.diag(w) @ U.T] * 2, axis=0)
673 S_nx = nx.from_numpy(S)
674 R = ot.utils.proj_SDP(S_nx)
675
676 w_expected = np.array([1.0, 0.0])
677 S_expected = np.stack([U @ np.diag(w_expected) @ U.T] * 2, axis=0)
678 assert np.allclose(nx.to_numpy(R), S_expected)
679
680 R0 = ot.utils.proj_SDP(S_nx[0])
681 assert np.allclose(nx.to_numpy(R0), S_expected[0])
682
683
684def test_laplacian():

Callers

nothing calls this directly

Calls 5

from_numpyMethod · 0.80
to_numpyMethod · 0.80
stackMethod · 0.45
diagMethod · 0.45
allcloseMethod · 0.45

Tested by

no test coverage detected