summaryrefslogtreecommitdiff
path: root/src/python/test/test_dtm.py
diff options
context:
space:
mode:
authorHind-M <hind.montassif@gmail.com>2022-02-02 11:34:48 +0100
committerHind-M <hind.montassif@gmail.com>2022-02-02 11:34:48 +0100
commit307f5f50a806168deb236e263c58dbed3f776ad0 (patch)
treee4d8a576970b3515acd7da156fe542874f1c9a7a /src/python/test/test_dtm.py
parentbeb431316a5181caf0eec5c0940601457340cc58 (diff)
parent7f1b8eb706c72921141b53e607d6e2aa28e2bf19 (diff)
Merge remote-tracking branch 'upstream/master' into cech_optimization
Diffstat (limited to 'src/python/test/test_dtm.py')
-rwxr-xr-xsrc/python/test/test_dtm.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/python/test/test_dtm.py b/src/python/test/test_dtm.py
index 0a52279e..e46d616c 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,14 @@ 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.]])
+
+ with warnings.catch_warnings(record=True) as w:
+ # TODO Test "keops" implementation as well when next version of pykeops (current is 1.5) is released (should fix the problem (cf. issue #543))
+ dtm = DistanceToMeasure(2, implementation="hnsw")
+ r = dtm.fit_transform(pts)
+ assert len(w) == 1
+ assert issubclass(w[0].category, RuntimeWarning)
+ assert "Overflow" in str(w[0].message)