'Generate indices to split data into training and test set.
Parameters
X : array-like, shape (n_samples, n_features)
Training data, where n_samples is the number of samples
and n_features is the number of features.
y : array-like, shape (n_samples,)
Always ignored, exists for compatibility.
groups : array-like, with shape (n_samples,), optional
Always ignored, exists for compatibility.
Returns
train : ndarray
The training set indices for that split.
test : ndarray
The testing set indices for that split.
Notes
Randomized CV splitters may return different results for each call of
split. You can make the results identical by setting ``random_state``
to an integer.'

def split(self, X, y=None, groups=None):

    (X, y, groups) = indexable(X, y, groups)
    n_samples = _num_samples(X)
    n_splits = self.n_splits
    n_folds = (n_splits + 1)
    if (n_folds > n_samples):
        raise ValueError('Cannot    have    number    of    folds    ={0}    greater    than    the    number    of    samples:    {1}.'.format(n_folds, n_samples))
    indices = np.arange(n_samples)
    test_size = (n_samples // n_folds)
    test_starts = range((test_size + (n_samples % n_folds)), n_samples, test_size)
    for test_start in test_starts:
        if (self.max_train_size and (self.max_train_size < test_start)):
            (yield (indices[(test_start - self.max_train_size):test_start], indices[test_start:(test_start + test_size)]))
        else:
            (yield (indices[:test_start], indices[test_start:(test_start + test_size)]))
