# Buggy code
def fit(self, X, y, sample_weight=None):
    """Fit the model according to the given training data.

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape (n_samples, n_features)
        Training vector, where n_samples is the number of samples and
        n_features is the number of features.

    y : array-like, shape (n_samples,)
        Target vector relative to X.

    sample_weight : array-like, shape (n_samples,) optional
        Array of weights that are assigned to individual samples.
        If not provided, then each sample is given unit weight.

        .. versionadded:: 0.17
           *sample_weight* support to LogisticRegression.

    Returns
    -------
    self : object
    """
    if not isinstance(self.C, numbers.Number) or self.C < 0:
        raise ValueError("Penalty term must be positive; got (C=%r)" % self.C)
    if not isinstance(self.max_iter, numbers.Number) or self.max_iter < 0:
        raise ValueError(
            "Maximum number of iteration must be positive;"
            " got (max_iter=%r)" % self.max_iter
        )
    if not isinstance(self.tol, numbers.Number) or self.tol < 0:
        raise ValueError(
            "Tolerance for stopping criteria must be positive; got (tol=%r)" % self.tol
        )

    if self.solver in ["newton-cg"]:
        _dtype = [np.float64, np.float32]
    else:
        _dtype = np.float64

    X, y = check_X_y(
        X,
        y,
        accept_sparse="csr",
        dtype=_dtype,
        order="C",
        accept_large_sparse=self.solver != "liblinear",
    )
    check_classification_targets(y)
    self.classes_ = np.unique(y)
    n_samples, n_features = X.shape

    _check_solver_option(self.solver, self.multi_class, self.penalty, self.dual)

    if self.solver == "liblinear":
        if self.n_jobs != 1:
            warnings.warn(
                "'n_jobs' > 1 does not have any effect when"
                " 'solver' is set to 'liblinear'. Got 'n_jobs'"
                " = {}.".format(self.n_jobs)
            )
        self.coef_, self.intercept_, n_iter_ = _fit_liblinear(
            X,
            y,
            self.C,
            self.fit_intercept,
            self.intercept_scaling,
            self.class_weight,
            self.penalty,
            self.dual,
            self.verbose,
            self.max_iter,
            self.tol,
            self.random_state,
            sample_weight=sample_weight,
        )
        self.n_iter_ = np.array([n_iter_])
        return self

    if self.solver in ["sag", "saga"]:
        max_squared_sum = row_norms(X, squared=True).max()
    else:
        max_squared_sum = None

    n_classes = len(self.classes_)
    classes_ = self.classes_
    if n_classes < 2:
        raise ValueError(
            "This solver needs samples of at least 2 classes"
            " in the data, but the data contains only one"
            " class: %r" % classes_[0]
        )

    if len(self.classes_) == 2:
        n_classes = 1
        classes_ = classes_[1:]

    if self.warm_start:
        warm_start_coef = getattr(self, "coef_", None)
    else:
        warm_start_coef = None
    if warm_start_coef is not None and self.fit_intercept:
        warm_start_coef = np.append(
            warm_start_coef, self.intercept_[:, np.newaxis], axis=1
        )

    self.coef_ = list()
    self.intercept_ = np.zeros(n_classes)

    # Hack so that we iterate only once for the multinomial case.
    if self.multi_class == "multinomial":
        classes_ = [None]
        warm_start_coef = [warm_start_coef]
    if warm_start_coef is None:
        warm_start_coef = [None] * n_classes

    path_func = delayed(logistic_regression_path)

    # The SAG solver releases the GIL so it's more efficient to use
    # threads for this solver.
    if self.solver in ["sag", "saga"]:
        prefer = "threads"
    else:
        prefer = "processes"
    fold_coefs_ = Parallel(n_jobs=self.n_jobs, verbose=self.verbose, prefer=prefer)(
        path_func(
            X,
            y,
            pos_class=class_,
            Cs=[self.C],
            fit_intercept=self.fit_intercept,
            tol=self.tol,
            verbose=self.verbose,
            solver=self.solver,
            multi_class=self.multi_class,
            max_iter=self.max_iter,
            class_weight=self.class_weight,
            check_input=False,
            random_state=self.random_state,
            coef=warm_start_coef_,
            penalty=self.penalty,
            max_squared_sum=max_squared_sum,
            sample_weight=sample_weight,
        )
        for class_, warm_start_coef_ in zip(classes_, warm_start_coef)
    )

    fold_coefs_, _, n_iter_ = zip(*fold_coefs_)
    self.n_iter_ = np.asarray(n_iter_, dtype=np.int32)[:, 0]

    if self.multi_class == "multinomial":
        self.coef_ = fold_coefs_[0][0]
    else:
        self.coef_ = np.asarray(fold_coefs_)
        self.coef_ = self.coef_.reshape(n_classes, n_features + int(self.fit_intercept))

    if self.fit_intercept:
        self.intercept_ = self.coef_[:, -1]
        self.coef_ = self.coef_[:, :-1]

    return self


# Traceback (ValueError)
Unexpected failing examples:
/home/circleci/project/examples/cluster/plot_feature_agglomeration_vs_univariate_selection.py failed leaving traceback:
Traceback (most recent call last):
File "/home/circleci/project/examples/cluster/plot_feature_agglomeration_vs_univariate_selection.py", line 75, in <module>
clf.fit(X, y)  # set the best parameters
File "/home/circleci/project/sklearn/model_selection/_search.py", line 663, in fit
cv.split(X, y, groups)))
File "/home/circleci/project/sklearn/externals/joblib/parallel.py", line 981, in __call__
if self.dispatch_one_batch(iterator):
File "/home/circleci/project/sklearn/externals/joblib/parallel.py", line 818, in dispatch_one_batch
self._pickle_cache)
File "/home/circleci/project/sklearn/externals/joblib/parallel.py", line 253, in __init__
self.items = list(iterator_slice)
File "/home/circleci/project/sklearn/model_selection/_search.py", line 662, in <genexpr>
for parameters, (train, test) in product(candidate_params,
File "/home/circleci/project/sklearn/base.py", line 62, in clone
new_object_params[name] = clone(param, safe=False)
File "/home/circleci/project/sklearn/base.py", line 50, in clone
return estimator_type([clone(e, safe=safe) for e in estimator])
File "/home/circleci/project/sklearn/base.py", line 50, in <listcomp>
return estimator_type([clone(e, safe=safe) for e in estimator])
File "/home/circleci/project/sklearn/base.py", line 50, in clone
return estimator_type([clone(e, safe=safe) for e in estimator])
File "/home/circleci/project/sklearn/base.py", line 50, in <listcomp>
return estimator_type([clone(e, safe=safe) for e in estimator])
File "/home/circleci/project/sklearn/base.py", line 62, in clone
new_object_params[name] = clone(param, safe=False)
File "/home/circleci/project/sklearn/base.py", line 53, in clone
return copy.deepcopy(estimator)
File "/home/circleci/miniconda/envs/testenv/lib/python3.6/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/home/circleci/miniconda/envs/testenv/lib/python3.6/copy.py", line 274, in _reconstruct
y = func(*args)
File "/home/circleci/project/sklearn/externals/joblib/memory.py", line 830, in __init__
location, cachedir))
ValueError: You set both "location='/tmp/tmp1v2mgts1' and "cachedir=False". 'cachedir' has been deprecated in version 0.12 and will be removed in version 0.14.
Please only set "location='/tmp/tmp1v2mgts1'"


/home/circleci/project/examples/compose/plot_compare_reduction.py failed leaving traceback:
Traceback (most recent call last):
File "/home/circleci/project/examples/compose/plot_compare_reduction.py", line 119, in <module>
grid.fit(digits.data, digits.target)
File "/home/circleci/project/sklearn/model_selection/_search.py", line 663, in fit
cv.split(X, y, groups)))
File "/home/circleci/project/sklearn/externals/joblib/parallel.py", line 981, in __call__
if self.dispatch_one_batch(iterator):
File "/home/circleci/project/sklearn/externals/joblib/parallel.py", line 818, in dispatch_one_batch
self._pickle_cache)
File "/home/circleci/project/sklearn/externals/joblib/parallel.py", line 253, in __init__
self.items = list(iterator_slice)
File "/home/circleci/project/sklearn/model_selection/_search.py", line 662, in <genexpr>
for parameters, (train, test) in product(candidate_params,
File "/home/circleci/project/sklearn/base.py", line 62, in clone
new_object_params[name] = clone(param, safe=False)
File "/home/circleci/project/sklearn/base.py", line 53, in clone
return copy.deepcopy(estimator)
File "/home/circleci/miniconda/envs/testenv/lib/python3.6/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/home/circleci/miniconda/envs/testenv/lib/python3.6/copy.py", line 274, in _reconstruct
y = func(*args)
File "/home/circleci/project/sklearn/externals/joblib/memory.py", line 830, in __init__
location, cachedir))
ValueError: You set both "location='/tmp/tmpa408j1cz' and "cachedir=False". 'cachedir' has been deprecated in version 0.12 and will be removed in version 0.14.
Please only set "location='/tmp/tmpa408j1cz'"

# Fixed code
def fit(self, X, y, sample_weight=None):
    """Fit the model according to the given training data.

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape (n_samples, n_features)
        Training vector, where n_samples is the number of samples and
        n_features is the number of features.

    y : array-like, shape (n_samples,)
        Target vector relative to X.

    sample_weight : array-like, shape (n_samples,) optional
        Array of weights that are assigned to individual samples.
        If not provided, then each sample is given unit weight.

        .. versionadded:: 0.17
           *sample_weight* support to LogisticRegression.

    Returns
    -------
    self : object
    """
    if not isinstance(self.C, numbers.Number) or self.C < 0:
        raise ValueError("Penalty term must be positive; got (C=%r)" % self.C)
    if not isinstance(self.max_iter, numbers.Number) or self.max_iter < 0:
        raise ValueError(
            "Maximum number of iteration must be positive;"
            " got (max_iter=%r)" % self.max_iter
        )
    if not isinstance(self.tol, numbers.Number) or self.tol < 0:
        raise ValueError(
            "Tolerance for stopping criteria must be positive; got (tol=%r)" % self.tol
        )

    if self.solver in ["newton-cg"]:
        _dtype = [np.float64, np.float32]
    else:
        _dtype = np.float64

    X, y = check_X_y(
        X,
        y,
        accept_sparse="csr",
        dtype=_dtype,
        order="C",
        accept_large_sparse=self.solver != "liblinear",
    )
    check_classification_targets(y)
    self.classes_ = np.unique(y)
    n_samples, n_features = X.shape

    _check_solver_option(self.solver, self.multi_class, self.penalty, self.dual)

    if self.solver == "liblinear":
        if effective_n_jobs(self.n_jobs) != 1:
            warnings.warn(
                "'n_jobs' > 1 does not have any effect when"
                " 'solver' is set to 'liblinear'. Got 'n_jobs'"
                " = {}.".format(effective_n_jobs(self.n_jobs))
            )
        self.coef_, self.intercept_, n_iter_ = _fit_liblinear(
            X,
            y,
            self.C,
            self.fit_intercept,
            self.intercept_scaling,
            self.class_weight,
            self.penalty,
            self.dual,
            self.verbose,
            self.max_iter,
            self.tol,
            self.random_state,
            sample_weight=sample_weight,
        )
        self.n_iter_ = np.array([n_iter_])
        return self

    if self.solver in ["sag", "saga"]:
        max_squared_sum = row_norms(X, squared=True).max()
    else:
        max_squared_sum = None

    n_classes = len(self.classes_)
    classes_ = self.classes_
    if n_classes < 2:
        raise ValueError(
            "This solver needs samples of at least 2 classes"
            " in the data, but the data contains only one"
            " class: %r" % classes_[0]
        )

    if len(self.classes_) == 2:
        n_classes = 1
        classes_ = classes_[1:]

    if self.warm_start:
        warm_start_coef = getattr(self, "coef_", None)
    else:
        warm_start_coef = None
    if warm_start_coef is not None and self.fit_intercept:
        warm_start_coef = np.append(
            warm_start_coef, self.intercept_[:, np.newaxis], axis=1
        )

    self.coef_ = list()
    self.intercept_ = np.zeros(n_classes)

    # Hack so that we iterate only once for the multinomial case.
    if self.multi_class == "multinomial":
        classes_ = [None]
        warm_start_coef = [warm_start_coef]
    if warm_start_coef is None:
        warm_start_coef = [None] * n_classes

    path_func = delayed(logistic_regression_path)

    # The SAG solver releases the GIL so it's more efficient to use
    # threads for this solver.
    if self.solver in ["sag", "saga"]:
        prefer = "threads"
    else:
        prefer = "processes"
    fold_coefs_ = Parallel(n_jobs=self.n_jobs, verbose=self.verbose, prefer=prefer)(
        path_func(
            X,
            y,
            pos_class=class_,
            Cs=[self.C],
            fit_intercept=self.fit_intercept,
            tol=self.tol,
            verbose=self.verbose,
            solver=self.solver,
            multi_class=self.multi_class,
            max_iter=self.max_iter,
            class_weight=self.class_weight,
            check_input=False,
            random_state=self.random_state,
            coef=warm_start_coef_,
            penalty=self.penalty,
            max_squared_sum=max_squared_sum,
            sample_weight=sample_weight,
        )
        for class_, warm_start_coef_ in zip(classes_, warm_start_coef)
    )

    fold_coefs_, _, n_iter_ = zip(*fold_coefs_)
    self.n_iter_ = np.asarray(n_iter_, dtype=np.int32)[:, 0]

    if self.multi_class == "multinomial":
        self.coef_ = fold_coefs_[0][0]
    else:
        self.coef_ = np.asarray(fold_coefs_)
        self.coef_ = self.coef_.reshape(n_classes, n_features + int(self.fit_intercept))

    if self.fit_intercept:
        self.intercept_ = self.coef_[:, -1]
        self.coef_ = self.coef_[:, :-1]

    return self