Skip to content

Commit 64cd571

Browse files
committed
test_jaccard_distance_numpy: Check for warning instead of printing it
1 parent 9a778e4 commit 64cd571

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Orange/tests/test_distances.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import scipy.spatial
1111
import scipy.stats
1212
from scipy.sparse import csr_matrix
13+
from sklearn.exceptions import DataConversionWarning
1314

1415
from Orange.data import (Table, Domain, ContinuousVariable,
1516
DiscreteVariable, StringVariable, Instance)
@@ -499,10 +500,13 @@ def test_jaccard_distance_many_examples(self):
499500
np.array([[0., 0., 0.5],
500501
[0., 0., 0.5]]))
501502

502-
def test_jaccard_distance_numpy(self):
503+
@patch("warnings.warn")
504+
def test_jaccard_distance_numpy(self, warn):
503505
np.testing.assert_almost_equal(
504506
self.dist(self.titanic[0].x, self.titanic[2].x, axis=1),
505507
np.array([[0.5]]))
508+
self.assertIs(warn.call_args[0][1], DataConversionWarning)
509+
warn.assert_called()
506510
np.testing.assert_almost_equal(
507511
self.dist(self.titanic.X),
508512
np.array([[0., 0., 0.5, 0.5],

0 commit comments

Comments
 (0)