# Buggy code
def fit(self, X, y, sample_weight=None):
    """Fit Naive Bayes classifier according to X, y

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape = [n_samples, n_features]
        Training vectors, where n_samples is the number of samples and
        n_features is the number of features.

    y : array-like, shape = [n_samples]
        Target values.

    sample_weight : array-like, shape = [n_samples], optional
        Weights applied to individual samples (1. for unweighted).

    Returns
    -------
    self : object
        Returns self.
    """
    X, y = check_arrays(X, y, sparse_format="csr")
    X = X.astype(np.float)
    y = column_or_1d(y, warn=True)
    _, n_features = X.shape

    labelbin = LabelBinarizer()
    Y = labelbin.fit_transform(y)
    self.classes_ = labelbin.classes_
    if Y.shape[1] == 1:
        Y = np.concatenate((1 - Y, Y), axis=1)

    # convert to float to support sample weight consistently
    Y = Y.astype(np.float64)
    if sample_weight is not None:
        Y *= array2d(sample_weight).T

    class_prior = self.class_prior

    # Count raw events from data before updating the class log prior
    # and feature log probas
    n_effective_classes = Y.shape[1]
    self.class_count_ = np.zeros(n_effective_classes, dtype=np.float64)
    self.feature_count_ = np.zeros((n_effective_classes, n_features), dtype=np.float64)
    self._count(X, Y)
    self._update_feature_log_prob()
    self._update_class_log_prior(class_prior=class_prior)
    return self


# Traceback (IndexError)
======================================================================
ERROR: sklearn.tests.test_common.test_regressors_train('RANSACRegressor', <class 'sklearn.linear_model.ransac.RANSACRegr
essor'>, array([[-0.44836249, -0.47282444, -1.20608008, ..., -0.75500806,
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\nose\case.py", line 197, in runTest
self.test(*self.arg)
File "C:\Python27\lib\site-packages\sklearn\tests\test_common.py", line 850, in check_regressors_train
assert_raises(ValueError, regressor.fit, X, y[:-1])
File "C:\Python27\lib\unittest\case.py", line 473, in assertRaises
callableObj(*args, **kwargs)
File "C:\Python27\lib\site-packages\sklearn\linear_model\ransac.py", line 261, in fit
y_subset = y[subset_idxs]
IndexError: index 199 is out of bounds for axis 0 with size 199

# Fixed code
def fit(self, X, y, sample_weight=None):
    """Fit Naive Bayes classifier according to X, y

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape = [n_samples, n_features]
        Training vectors, where n_samples is the number of samples and
        n_features is the number of features.

    y : array-like, shape = [n_samples]
        Target values.

    sample_weight : array-like, shape = [n_samples], optional
        Weights applied to individual samples (1. for unweighted).

    Returns
    -------
    self : object
        Returns self.
    """
    X, y = check_arrays(X, y, sparse_format="csr")
    y = column_or_1d(y, warn=True)
    _, n_features = X.shape

    labelbin = LabelBinarizer()
    Y = labelbin.fit_transform(y)
    self.classes_ = labelbin.classes_
    if Y.shape[1] == 1:
        Y = np.concatenate((1 - Y, Y), axis=1)

    # convert to float to support sample weight consistently;
    # this means we also don't have to cast X to floating point
    Y = Y.astype(np.float64)
    if sample_weight is not None:
        Y *= array2d(sample_weight).T

    class_prior = self.class_prior

    # Count raw events from data before updating the class log prior
    # and feature log probas
    n_effective_classes = Y.shape[1]
    self.class_count_ = np.zeros(n_effective_classes, dtype=np.float64)
    self.feature_count_ = np.zeros((n_effective_classes, n_features), dtype=np.float64)
    self._count(X, Y)
    self._update_feature_log_prob()
    self._update_class_log_prior(class_prior=class_prior)
    return self