summaryrefslogtreecommitdiff
path: root/src/python/test/test_dtm.py
diff options
context:
space:
mode:
authorVincent Rouvreau <vincent.rouvreau@inria.fr>2021-11-08 10:47:09 +0100
committerVincent Rouvreau <vincent.rouvreau@inria.fr>2021-11-08 10:47:09 +0100
commitd670769d113c7621d2260ac08c2961dd73ce8cb4 (patch)
treef4080ecfda544a2c4062d9ca24e4091cf6ea48ea /src/python/test/test_dtm.py
parent11b8a288946c953472165ffbb5dbfbeb5ca64d26 (diff)
parentcfb60a50a7c3aea08abc41118fbfdf31061a44a4 (diff)
Merge master and resolve conflicts (mainly src/python/CMakeLists.txt)
Diffstat (limited to 'src/python/test/test_dtm.py')
-rwxr-xr-xsrc/python/test/test_dtm.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/python/test/test_dtm.py b/src/python/test/test_dtm.py
index 0a52279e..c29471cf 100755
--- a/src/python/test/test_dtm.py
+++ b/src/python/test/test_dtm.py
@@ -13,6 +13,7 @@ import numpy
import pytest
import torch
import math
+import warnings
def test_dtm_compare_euclidean():
@@ -87,3 +88,16 @@ def test_density():
assert density == pytest.approx(expected)
density = DTMDensity(weights=[0.5, 0.5], metric="neighbors", dim=1).fit_transform(distances)
assert density == pytest.approx(expected)
+
+def test_dtm_overflow_warnings():
+ pts = numpy.array([[10., 100000000000000000000000000000.], [1000., 100000000000000000000000000.]])
+ impl_warn = ["keops", "hnsw"]
+
+ with warnings.catch_warnings(record=True) as w:
+ for impl in impl_warn:
+ dtm = DistanceToMeasure(2, q=10000, implementation=impl)
+ r = dtm.fit_transform(pts)
+ assert len(w) == 2
+ for i in range(len(w)):
+ assert issubclass(w[i].category, RuntimeWarning)
+ assert "Overflow" in str(w[i].message)