@@ -203,10 +203,11 @@ def test_array_basis(self, estimator, data):
203203 def test_verbose (self , estimator , data , capsys ):
204204 # assert there is proper output when verbose = True
205205 model = estimator (preprocessor = np .array ([[0 , 0 ], [1 , 1 ], [2 , 2 ], [3 , 3 ]]),
206- max_iter = 1 , output_iter = 1 , batch_size = 1 , verbose = True )
206+ max_iter = 1 , output_iter = 1 , batch_size = 1 , basis = 'triplet_diffs' ,
207+ random_state = 42 , verbose = True )
207208 model .fit (* data )
208209 out , _ = capsys .readouterr ()
209- expected_out = ('[%s] iter 1\t obj 1.000000 \t num_imp 8 \n '
210+ expected_out = ('[%s] iter 1\t obj 0.569946 \t num_imp 2 \n '
210211 'max iteration reached.\n ' % estimator .__name__ )
211212 assert out == expected_out
212213
@@ -276,6 +277,52 @@ def test_lda(self, n_samples, n_features, n_classes):
276277 assert n_basis == expected_n_basis
277278 assert basis .shape == expected_shape
278279
280+ @pytest .mark .parametrize ('name' , ['max_iter' , 'output_iter' , 'batch_size' ,
281+ 'n_basis' ])
282+ def test_int_inputs (self , name ):
283+ value = 1.0
284+ d = {name : value }
285+ scml = SCML (** d )
286+ triplets = np .array ([[[0 , 1 ], [2 , 1 ], [0 , 0 ]],
287+ [[2 , 1 ], [0 , 1 ], [2 , 0 ]],
288+ [[0 , 0 ], [2 , 0 ], [0 , 1 ]],
289+ [[2 , 0 ], [0 , 0 ], [2 , 1 ]]])
290+
291+ msg = name
292+ msg += (" should be an integer, instead it is of type"
293+ " %s" % type (value ))
294+ with pytest .raises (ValueError ) as raised_error :
295+ scml .fit (triplets )
296+ assert msg == raised_error .value .args [0 ]
297+
298+ @pytest .mark .parametrize ('name' , ['max_iter' , 'output_iter' , 'batch_size' ,
299+ 'k_genuine' , 'k_impostor' , 'n_basis' ])
300+ def test_int_inputs_supervised (self , name ):
301+ value = 1.0
302+ d = {name : value }
303+ scml = SCML_Supervised (** d )
304+ X = np .array ([[0 , 0 ], [1 , 1 ], [3 , 3 ], [4 , 4 ]])
305+ y = np .array ([1 , 1 , 0 , 0 ])
306+ msg = name
307+ msg += (" should be an integer, instead it is of type"
308+ " %s" % type (value ))
309+ with pytest .raises (ValueError ) as raised_error :
310+ scml .fit (X , y )
311+ assert msg == raised_error .value .args [0 ]
312+
313+ def test_large_output_iter (self ):
314+ scml = SCML (max_iter = 1 , output_iter = 2 )
315+ triplets = np .array ([[[0 , 1 ], [2 , 1 ], [0 , 0 ]],
316+ [[2 , 1 ], [0 , 1 ], [2 , 0 ]],
317+ [[0 , 0 ], [2 , 0 ], [0 , 1 ]],
318+ [[2 , 0 ], [0 , 0 ], [2 , 1 ]]])
319+ msg = ("The value of output_iter must be equal or smaller than"
320+ " max_iter." )
321+
322+ with pytest .raises (ValueError ) as raised_error :
323+ scml .fit (triplets )
324+ assert msg == raised_error .value .args [0 ]
325+
279326
280327class TestLSML (MetricTestCase ):
281328 def test_iris (self ):
0 commit comments