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

Function test_linear_mapping_class

test/test_da.py:659–689  ·  view source on GitHub ↗
(nx)

Source from the content-addressed store, hash-verified

657@pytest.skip_backend("jax")
658@pytest.skip_backend("tf")
659def test_linear_mapping_class(nx):
660 ns = 50
661 nt = 50
662
663 Xs, ys = make_data_classif("3gauss", ns)
664 Xt, yt = make_data_classif("3gauss2", nt)
665
666 Xsb, Xtb = nx.from_numpy(Xs, Xt)
667
668 for log in [True, False]:
669 otmap = ot.da.LinearTransport(log=log)
670
671 otmap.fit(Xs=Xsb, Xt=Xtb)
672 assert hasattr(otmap, "A_")
673 assert hasattr(otmap, "B_")
674 assert hasattr(otmap, "A1_")
675 assert hasattr(otmap, "B1_")
676
677 Xst = nx.to_numpy(otmap.transform(Xs=Xsb))
678
679 Ct = np.cov(Xt.T)
680 Cst = np.cov(Xst.T)
681
682 np.testing.assert_allclose(Ct, Cst, rtol=1e-2, atol=1e-2)
683
684 Xts = nx.to_numpy(otmap.inverse_transform(Xt=Xtb))
685
686 Cs = np.cov(Xs.T)
687 Cts = np.cov(Xts.T)
688
689 np.testing.assert_allclose(Cs, Cts, rtol=1e-2, atol=1e-2)
690
691
692@pytest.skip_backend("jax")

Callers

nothing calls this directly

Calls 6

fitMethod · 0.95
transformMethod · 0.95
inverse_transformMethod · 0.95
make_data_classifFunction · 0.90
from_numpyMethod · 0.80
to_numpyMethod · 0.80

Tested by

no test coverage detected