Enable grid_search with classifiers that fail on individual training folds

Enable grid_search with classifiers that fail on individual training folds.

The improved functionality is repeated in two places, with the same code for the case where y is not None and when y is None. I would welcome a suggestion on how to avoid this duplication. There are also two nearly identical tests for those two cases.