# Buggy code
def predict(self, X):
    """Predict the class labels for the provided data

    Parameters
    ----------
    X : array of shape [n_samples, n_features]
        A 2-D array representing the test points.

    Returns
    -------
    y : array of shape [n_samples] or [n_samples, n_outputs]
        Class labels for each data sample.

    """
    X = atleast2d_or_csr(X)
    n_samples = X.shape[0]

    neigh_dist, neigh_ind = self.radius_neighbors(X)
    inliers = [i for i, nind in enumerate(neigh_ind) if len(nind) != 0]
    outliers = [i for i, nind in enumerate(neigh_ind) if len(nind) == 0]

    classes_ = self.classes_
    _y = self._y
    if not self.outputs_2d_:
        _y = self._y.reshape((-1, 1))
        classes_ = [self.classes_]
    n_outputs = len(classes_)

    if self.outlier_label is not None:
        neigh_dist[outliers] = 1e-6
    elif outliers:
        raise ValueError(
            "No neighbors found for test samples %r, "
            "you can try using larger radius, "
            "give a label for outliers, "
            "or consider removing them from your dataset." % outliers
        )

    weights = _get_weights(neigh_dist, self.weights)

    y_pred = np.empty((n_samples, n_outputs), dtype=classes_[0].dtype)
    for k, classes_k in enumerate(classes_):
        pred_labels = np.array([_y[ind, k] for ind in neigh_ind], dtype=object)
        if weights is None:
            mode = np.array(
                [stats.mode(pl)[0] for pl in pred_labels[inliers]], dtype=np.int
            )
        else:
            mode = np.array(
                [
                    weighted_mode(pl, w)[0]
                    for (pl, w) in zip(pred_labels[inliers], weights)
                ],
                dtype=np.int,
            )

        mode = mode.ravel().astype(np.int)

        y_pred[inliers, k] = classes_k.take(mode)

    if outliers:
        y_pred[outliers, :] = self.outlier_label

    if not self.outputs_2d_:
        y_pred = y_pred.ravel()

    return y_pred


# 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 predict(self, X):
    """Predict the class labels for the provided data

    Parameters
    ----------
    X : array of shape [n_samples, n_features]
        A 2-D array representing the test points.

    Returns
    -------
    y : array of shape [n_samples] or [n_samples, n_outputs]
        Class labels for each data sample.

    """
    X = atleast2d_or_csr(X)
    n_samples = X.shape[0]

    neigh_dist, neigh_ind = self.radius_neighbors(X)
    inliers = [i for i, nind in enumerate(neigh_ind) if len(nind) != 0]
    outliers = [i for i, nind in enumerate(neigh_ind) if len(nind) == 0]

    classes_ = self.classes_
    _y = self._y
    if not self.outputs_2d_:
        _y = self._y.reshape((-1, 1))
        classes_ = [self.classes_]
    n_outputs = len(classes_)

    if self.outlier_label is not None:
        neigh_dist[outliers] = 1e-6
    elif outliers:
        raise ValueError(
            "No neighbors found for test samples %r, "
            "you can try using larger radius, "
            "give a label for outliers, "
            "or consider removing them from your dataset." % outliers
        )

    weights = _get_weights(neigh_dist, self.weights)

    y_pred = np.empty((n_samples, n_outputs), dtype=classes_[0].dtype)
    for k, classes_k in enumerate(classes_):
        pred_labels = np.array([_y[ind, k] for ind in neigh_ind], dtype=object)
        if weights is None:
            mode = np.array(
                [stats.mode(pl)[0] for pl in pred_labels[inliers]], dtype=np.int
            )
        else:
            mode = np.array(
                [
                    weighted_mode(pl, w)[0]
                    for (pl, w) in zip(pred_labels[inliers], weights)
                ],
                dtype=np.int,
            )

        mode = mode.ravel()

        y_pred[inliers, k] = classes_k.take(mode)

    if outliers:
        y_pred[outliers, :] = self.outlier_label

    if not self.outputs_2d_:
        y_pred = y_pred.ravel()

    return y_pred