44from numpy .testing import assert_array_almost_equal
55import pytest
66from metric_learn ._util import make_context
7- from sklearn import clone
87from sklearn .cluster import DBSCAN
98
9+
1010class IdentityBilinearMixin (BilinearMixin ):
1111 """A simple Identity bilinear mixin that returns an identity matrix
1212 M as learned. Can change M for a random matrix calling random_M.
@@ -55,6 +55,7 @@ def test_check_correctness_similarity():
5555 assert_array_almost_equal (dist1 , desired ) # score_pairs
5656 assert_array_almost_equal (dist2 , desired ) # get_metric
5757
58+
5859def test_check_handmade_example ():
5960 u = np .array ([0 , 1 , 2 ])
6061 v = np .array ([3 , 4 , 5 ])
@@ -104,8 +105,8 @@ def test_score_pairs_dim():
104105 assert mixin .score_pairs (tuples ).shape == (tuples .shape [0 ],)
105106 context = make_context (mixin )
106107 msg = ("3D array of formed tuples expected{}. Found 2D array "
107- "instead:\n input={}. Reshape your data and/or use a preprocessor.\n "
108- .format (context , tuples [1 ]))
108+ "instead:\n input={}. Reshape your data and/or use a preprocessor.\n "
109+ .format (context , tuples [1 ]))
109110 with pytest .raises (ValueError ) as raised_error :
110111 mixin .score_pairs (tuples [1 ])
111112 assert str (raised_error .value ) == msg
@@ -122,4 +123,4 @@ def test_check_scikitlearn_compatibility():
122123 n = 100
123124 X = np .array ([np .random .rand (d ) for i in range (n )])
124125 clustering = DBSCAN (metric = mixin .get_metric ())
125- clustering .fit (X )
126+ clustering .fit (X )
0 commit comments