@@ -325,7 +325,7 @@ def f_missing(a, b):
325
325
return c
326
326
327
327
328
- def f_check_param_definition (a , b , c , d ):
328
+ def f_check_param_definition (a , b , c , d , e ):
329
329
"""Function f
330
330
331
331
Parameters
@@ -338,6 +338,8 @@ def f_check_param_definition(a, b, c, d):
338
338
Parameter c
339
339
d:int
340
340
Parameter d
341
+ e
342
+ No typespec is allowed without colon
341
343
"""
342
344
return a + b + c + d
343
345
@@ -402,8 +404,8 @@ def predict(self, X):
402
404
"""
403
405
return self .delegate .predict (X )
404
406
405
- @deprecated ("Testing a deprecated delegated method" )
406
407
@if_delegate_has_method (delegate = ('delegate' ))
408
+ @deprecated ("Testing a deprecated delegated method" )
407
409
def score (self , X ):
408
410
"""This is available only if delegate has score.
409
411
@@ -424,20 +426,7 @@ def predict_proba(self, X):
424
426
"""
425
427
return X
426
428
427
- @deprecated ('Testing deprecated function with incorrect params' )
428
- @if_delegate_has_method (delegate = ('delegate' ))
429
- def predict_log_proba (self , X ):
430
- """This is available only if delegate has predict_proba.
431
-
432
- Parameters
433
- ---------
434
- y : ndarray
435
- Parameter X
436
- """
437
- return X
438
-
439
429
@deprecated ('Testing deprecated function with wrong params' )
440
- @if_delegate_has_method (delegate = ('delegate' ))
441
430
def fit (self , X , y ):
442
431
"""Incorrect docstring but should not be tested"""
443
432
@@ -451,20 +440,32 @@ def test_check_docstring_parameters():
451
440
"numpydoc is required to test the docstrings" )
452
441
453
442
incorrect = check_docstring_parameters (f_ok )
454
- assert_equal ( incorrect , [])
443
+ assert incorrect == []
455
444
incorrect = check_docstring_parameters (f_ok , ignore = ['b' ])
456
- assert_equal ( incorrect , [])
445
+ assert incorrect == []
457
446
incorrect = check_docstring_parameters (f_missing , ignore = ['b' ])
458
- assert_equal ( incorrect , [])
447
+ assert incorrect == []
459
448
assert_raise_message (RuntimeError , 'Unknown section Results' ,
460
449
check_docstring_parameters , f_bad_sections )
461
450
assert_raise_message (RuntimeError , 'Unknown section Parameter' ,
462
451
check_docstring_parameters , Klass .f_bad_sections )
463
452
453
+ incorrect = check_docstring_parameters (f_check_param_definition )
454
+ assert (
455
+ incorrect == [
456
+ "sklearn.utils.tests.test_testing.f_check_param_definition There "
457
+ "was no space between the param name and colon ('a: int')" ,
458
+ "sklearn.utils.tests.test_testing.f_check_param_definition There "
459
+ "was no space between the param name and colon ('b:')" ,
460
+ "sklearn.utils.tests.test_testing.f_check_param_definition "
461
+ "Parameter 'c :' has an empty type spec. Remove the colon" ,
462
+ "sklearn.utils.tests.test_testing.f_check_param_definition There "
463
+ "was no space between the param name and colon ('d:int')" ,
464
+ ])
465
+
464
466
messages = ["a != b" , "arg mismatch: ['b']" , "arg mismatch: ['X', 'y']" ,
465
467
"predict y != X" ,
466
468
"predict_proba arg mismatch: ['X']" ,
467
- "predict_log_proba arg mismatch: ['X']" ,
468
469
"score arg mismatch: ['X']" ,
469
470
".fit arg mismatch: ['X', 'y']" ]
470
471
@@ -473,21 +474,7 @@ def test_check_docstring_parameters():
473
474
for mess , f in zip (messages ,
474
475
[f_bad_order , f_missing , Klass .f_missing ,
475
476
mock_meta .predict , mock_meta .predict_proba ,
476
- mock_meta .predict_log_proba ,
477
477
mock_meta .score , mock_meta .fit ]):
478
478
incorrect = check_docstring_parameters (f )
479
- assert_true (len (incorrect ) >= 1 )
480
- assert_true (mess in incorrect [0 ],
481
- '"%s" not in "%s"' % (mess , incorrect [0 ]))
482
-
483
- incorrect = check_docstring_parameters (f_check_param_definition )
484
- assert_equal (
485
- incorrect ,
486
- ['sklearn.utils.tests.test_testing.f_check_param_definition There was '
487
- 'no space between the param name and colon ("a: int")' ,
488
- 'sklearn.utils.tests.test_testing.f_check_param_definition There was '
489
- 'no space between the param name and colon ("b:")' ,
490
- 'sklearn.utils.tests.test_testing.f_check_param_definition Incorrect '
491
- 'type definition for param: "c " (type definition was "")' ,
492
- 'sklearn.utils.tests.test_testing.f_check_param_definition There was '
493
- 'no space between the param name and colon ("d:int")' ])
479
+ assert len (incorrect ) >= 1
480
+ assert mess in incorrect [0 ], '"%s" not in "%s"' % (mess , incorrect [0 ])
0 commit comments