diff options
author | Gard Spreemann <gspr@nonempty.org> | 2023-06-14 16:51:31 +0200 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2023-06-14 16:51:31 +0200 |
commit | 96788a3fe5601e4c3f49b592aa0d9c034247862e (patch) | |
tree | 5ee3ebcdea05f6766fc9858344913e40487e9067 /test/test_utils.py | |
parent | 35bd2c98b642df78638d7d733bc1a89d873db1de (diff) | |
parent | 89f1613861152432807077fbb146578611dc5888 (diff) |
Merge tag '0.9.0' into dfsg/latestdfsg/latest
Diffstat (limited to 'test/test_utils.py')
-rw-r--r-- | test/test_utils.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py index 3cfd295..31b12ef 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -143,6 +143,7 @@ def test_dist(): for metric in metrics_w: print(metric) ot.dist(x, x, metric=metric, p=3, w=np.random.random((2, ))) + ot.dist(x, x, metric=metric, p=3, w=None) # check that not having any weight does not cause issues for metric in metrics: print(metric) ot.dist(x, x, metric=metric, p=3) @@ -300,3 +301,42 @@ def test_BaseEstimator(): cl.set_params(bibi=10) assert cl.first == 'spam again' + + +def test_OTResult(): + + res = ot.utils.OTResult() + + # test print + print(res) + + # tets get citation + print(res.citation) + + lst_attributes = ['a_to_b', + 'b_to_a', + 'lazy_plan', + 'marginal_a', + 'marginal_b', + 'marginals', + 'plan', + 'potential_a', + 'potential_b', + 'potentials', + 'sparse_plan', + 'status', + 'value', + 'value_linear'] + for at in lst_attributes: + with pytest.raises(NotImplementedError): + getattr(res, at) + + +def test_get_coordinate_circle(): + + u = np.random.rand(1, 100) + x1, y1 = np.cos(u * (2 * np.pi)), np.sin(u * (2 * np.pi)) + x = np.concatenate([x1, y1]).T + x_p = ot.utils.get_coordinate_circle(x) + + np.testing.assert_allclose(u[0], x_p) |