File tree 2 files changed +13
-8
lines changed
2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -385,9 +385,10 @@ def _check_param_grid(param_grid):
385
385
386
386
if (isinstance (v , str ) or
387
387
not isinstance (v , (np .ndarray , Sequence ))):
388
- raise ValueError ("Parameter values for parameter ({0}) need "
389
- "to be a sequence(but not a string) or"
390
- " np.ndarray." .format (name ))
388
+ raise ValueError ("Parameter grid for parameter ({0}) needs to"
389
+ " be a list or numpy array, but got ({1})."
390
+ " Single values need to be wrapped in a list"
391
+ " with one element." .format (name , type (v )))
391
392
392
393
if len (v ) == 0 :
393
394
raise ValueError ("Parameter values for parameter ({0}) need "
Original file line number Diff line number Diff line change @@ -428,12 +428,14 @@ def test_grid_search_when_param_grid_includes_range():
428
428
429
429
430
430
def test_grid_search_bad_param_grid ():
431
- param_dict = {"C" : 1.0 }
431
+ param_dict = {"C" : 1 }
432
432
clf = SVC (gamma = 'auto' )
433
433
assert_raise_message (
434
434
ValueError ,
435
- "Parameter values for parameter (C) need to be a sequence"
436
- "(but not a string) or np.ndarray." ,
435
+ "Parameter grid for parameter (C) needs to"
436
+ " be a list or numpy array, but got (<class 'int'>)."
437
+ " Single values need to be wrapped in a list"
438
+ " with one element." ,
437
439
GridSearchCV , clf , param_dict )
438
440
439
441
param_dict = {"C" : []}
@@ -447,8 +449,10 @@ def test_grid_search_bad_param_grid():
447
449
clf = SVC (gamma = 'auto' )
448
450
assert_raise_message (
449
451
ValueError ,
450
- "Parameter values for parameter (C) need to be a sequence"
451
- "(but not a string) or np.ndarray." ,
452
+ "Parameter grid for parameter (C) needs to"
453
+ " be a list or numpy array, but got (<class 'str'>)."
454
+ " Single values need to be wrapped in a list"
455
+ " with one element." ,
452
456
GridSearchCV , clf , param_dict )
453
457
454
458
param_dict = {"C" : np .ones ((3 , 2 ))}
You can’t perform that action at this time.
0 commit comments