summaryrefslogtreecommitdiff
path: root/test/test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_utils.py')
-rw-r--r--test/test_utils.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index 6b476b2..3cfd295 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -62,12 +62,14 @@ def test_tic_toc():
import time
ot.tic()
- time.sleep(0.5)
+ time.sleep(0.1)
t = ot.toc()
t2 = ot.toq()
# test timing
- np.testing.assert_allclose(0.5, t, rtol=1e-1, atol=1e-1)
+ # np.testing.assert_allclose(0.1, t, rtol=1e-1, atol=1e-1)
+ # very slow macos github action equality not possible
+ assert t > 0.09
# test toc vs toq
np.testing.assert_allclose(t, t2, rtol=1e-1, atol=1e-1)
@@ -94,10 +96,22 @@ def test_unif():
np.testing.assert_allclose(1, np.sum(u))
-def test_dist():
+def test_unif_backend(nx):
n = 100
+ for tp in nx.__type_list__:
+ print(nx.dtype_device(tp))
+
+ u = ot.unif(n, type_as=tp)
+
+ np.testing.assert_allclose(1, np.sum(nx.to_numpy(u)), atol=1e-6)
+
+
+def test_dist():
+
+ n = 10
+
rng = np.random.RandomState(0)
x = rng.randn(n, 2)
@@ -122,7 +136,7 @@ def test_dist():
'braycurtis', 'canberra', 'chebyshev', 'cityblock', 'correlation', 'cosine', 'dice',
'euclidean', 'hamming', 'jaccard', 'kulsinski',
'matching', 'minkowski', 'rogerstanimoto', 'russellrao',
- 'sokalmichener', 'sokalsneath', 'sqeuclidean', 'wminkowski', 'yule'
+ 'sokalmichener', 'sokalsneath', 'sqeuclidean', 'yule'
] # those that support weights
metrics = ['mahalanobis', 'seuclidean'] # do not support weights depending on scipy's version