(nx)
| 657 | @pytest.skip_backend("jax") |
| 658 | @pytest.skip_backend("tf") |
| 659 | def 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") |
nothing calls this directly
no test coverage detected