(sol1, sol2)
| 73 | |
| 74 | |
| 75 | def assert_allclose_sol(sol1, sol2): |
| 76 | lst_attr = [ |
| 77 | "value", |
| 78 | "value_linear", |
| 79 | "plan", |
| 80 | "potential_a", |
| 81 | "potential_b", |
| 82 | "marginal_a", |
| 83 | "marginal_b", |
| 84 | ] |
| 85 | |
| 86 | nx1 = sol1._backend if sol1._backend is not None else ot.backend.NumpyBackend() |
| 87 | nx2 = sol2._backend if sol2._backend is not None else ot.backend.NumpyBackend() |
| 88 | |
| 89 | for attr in lst_attr: |
| 90 | if getattr(sol1, attr) is not None and getattr(sol2, attr) is not None: |
| 91 | try: |
| 92 | np.allclose( |
| 93 | nx1.to_numpy(getattr(sol1, attr)), |
| 94 | nx2.to_numpy(getattr(sol2, attr)), |
| 95 | equal_nan=True, |
| 96 | ) |
| 97 | except NotImplementedError: |
| 98 | pass |
| 99 | elif getattr(sol1, attr) is None and getattr(sol2, attr) is None: |
| 100 | return True |
| 101 | else: |
| 102 | return False |
| 103 | |
| 104 | |
| 105 | def test_solve(nx): |
no test coverage detected