# Buggy code
def fit(self, X, y, sample_weight=None):
    """Fit the calibrated model

    Parameters
    ----------
    X : array-like, shape (n_samples, n_features)
        Training data.

    y : array-like, shape (n_samples,)
        Target values.

    sample_weight : array-like, shape = [n_samples] or None
        Sample weights. If None, then samples are equally weighted.

    Returns
    -------
    self : object
        Returns an instance of self.
    """
    X, y = check_X_y(X, y, accept_sparse=["csc", "csr", "coo"])
    X, y = indexable(X, y)
    lb = LabelBinarizer().fit(y)
    self.classes_ = lb.classes_

    # Check that we each cross-validation fold can have at least one
    # example per class
    n_folds = (
        self.cv
        if isinstance(self.cv, int)
        else self.cv.n_folds
        if hasattr(self.cv, "n_folds")
        else None
    )
    if n_folds and np.any([np.sum(y == class_) < n_folds for class_ in self.classes_]):
        raise ValueError(
            "Requesting %d-fold cross-validation but provided"
            " less than %d examples for at least one class." % (n_folds, n_folds)
        )

    self.calibrated_classifiers_ = []
    if self.base_estimator is None:
        base_estimator = LinearSVC()
    else:
        base_estimator = self.base_estimator

    if self.cv == "prefit":
        calibrated_classifier = _CalibratedClassifier(
            base_estimator, method=self.method
        )
        if sample_weight is not None:
            calibrated_classifier.fit(X, y, sample_weight)
        else:
            calibrated_classifier.fit(X, y)
        self.calibrated_classifiers_.append(calibrated_classifier)
    else:
        cv = _check_cv(self.cv, X, y, classifier=True)
        arg_names = inspect.getargspec(base_estimator.fit)[0]
        estimator_name = type(base_estimator).__name__
        if sample_weight is not None and "sample_weight" not in arg_names:
            warnings.warn(
                "%s does not support sample_weight. Samples"
                " weights are only used for the calibration"
                " itself." % estimator_name
            )
            base_estimator_sample_weight = None
        else:
            base_estimator_sample_weight = sample_weight
        for train, test in cv:
            this_estimator = clone(base_estimator)
            if base_estimator_sample_weight is not None:
                this_estimator.fit(
                    X[train],
                    y[train],
                    sample_weight=base_estimator_sample_weight[train],
                )
            else:
                this_estimator.fit(X[train], y[train])

            calibrated_classifier = _CalibratedClassifier(
                this_estimator, method=self.method
            )
            if sample_weight is not None:
                calibrated_classifier.fit(X[test], y[test], sample_weight[test])
            else:
                calibrated_classifier.fit(X[test], y[test])
            self.calibrated_classifiers_.append(calibrated_classifier)

    return self


# Traceback (AssertionError)
======================================================================
FAIL: Tests that class_weight and sample_weight are multiplicative
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/buildd/scikit-learn-0.16.0~b1+git1-gab4d07d/debian/python-sklearn/usr/lib/python2.7/dist-packages/sklearn/linear_model/tests/test_sgd.py", line 633, in test_weights_multiplied
assert_array_equal(clf1.coef_, clf2.coef_)
File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 718, in assert_array_equal
verbose=verbose, header='Arrays are not equal')
File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 644, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not equal

(mismatch 16.6666666667%)
x: array([[-0.34681637, -0.32240913, -0.31335029,  0.34920789,  0.3658206 ,
0.38752489]])
y: array([[-0.34681637, -0.32240913, -0.31335029,  0.34920789,  0.3658206 ,
0.38752489]])

# Fixed code
def fit(self, X, y, sample_weight=None):
    """Fit the calibrated model

    Parameters
    ----------
    X : array-like, shape (n_samples, n_features)
        Training data.

    y : array-like, shape (n_samples,)
        Target values.

    sample_weight : array-like, shape = [n_samples] or None
        Sample weights. If None, then samples are equally weighted.

    Returns
    -------
    self : object
        Returns an instance of self.
    """
    X, y = check_X_y(X, y, accept_sparse=["csc", "csr", "coo"], force_all_finite=False)
    X, y = indexable(X, y)
    lb = LabelBinarizer().fit(y)
    self.classes_ = lb.classes_

    # Check that we each cross-validation fold can have at least one
    # example per class
    n_folds = (
        self.cv
        if isinstance(self.cv, int)
        else self.cv.n_folds
        if hasattr(self.cv, "n_folds")
        else None
    )
    if n_folds and np.any([np.sum(y == class_) < n_folds for class_ in self.classes_]):
        raise ValueError(
            "Requesting %d-fold cross-validation but provided"
            " less than %d examples for at least one class." % (n_folds, n_folds)
        )

    self.calibrated_classifiers_ = []
    if self.base_estimator is None:
        base_estimator = LinearSVC()
    else:
        base_estimator = self.base_estimator

    if self.cv == "prefit":
        calibrated_classifier = _CalibratedClassifier(
            base_estimator, method=self.method
        )
        if sample_weight is not None:
            calibrated_classifier.fit(X, y, sample_weight)
        else:
            calibrated_classifier.fit(X, y)
        self.calibrated_classifiers_.append(calibrated_classifier)
    else:
        cv = _check_cv(self.cv, X, y, classifier=True)
        arg_names = inspect.getargspec(base_estimator.fit)[0]
        estimator_name = type(base_estimator).__name__
        if sample_weight is not None and "sample_weight" not in arg_names:
            warnings.warn(
                "%s does not support sample_weight. Samples"
                " weights are only used for the calibration"
                " itself." % estimator_name
            )
            base_estimator_sample_weight = None
        else:
            base_estimator_sample_weight = sample_weight
        for train, test in cv:
            this_estimator = clone(base_estimator)
            if base_estimator_sample_weight is not None:
                this_estimator.fit(
                    X[train],
                    y[train],
                    sample_weight=base_estimator_sample_weight[train],
                )
            else:
                this_estimator.fit(X[train], y[train])

            calibrated_classifier = _CalibratedClassifier(
                this_estimator, method=self.method
            )
            if sample_weight is not None:
                calibrated_classifier.fit(X[test], y[test], sample_weight[test])
            else:
                calibrated_classifier.fit(X[test], y[test])
            self.calibrated_classifiers_.append(calibrated_classifier)

    return self