def split(self, X, y=None, groups=None):
X, y, groups = indexable(X, y, groups)<EOL>cgrs = [~r for r in X]<EOL>structure_condition = defaultdict(set)<EOL>for structure, condition in zip(cgrs, groups):<EOL><INDENT>structure_condition[structure].add(condition)<EOL><DEDENT>train_data = defaultdict(list)<EOL>test_data = []<EOL>for n, (structure, condition) in enumerate(zip(cgrs, groups)):<EOL><INDENT>train_data[condition].append(n)<EOL>if len(structure_condition[structure]) > <NUM_LIT:1>:<EOL><INDENT>test_data.append(n)<EOL><DEDENT><DEDENT>for condition, indexes in train_data.items():<EOL><INDENT>test_index = [index for index in indexes if index in test_data]<EOL>if test_index:<EOL><INDENT>train_index = [i for cond, ind in train_data.items() if cond != condition for i in ind]<EOL>yield array(train_index), array(test_index)<EOL><DEDENT><DEDENT>
Generate indices to split data into training and test set.
        Parameters
        ----------
        X : array-like, of length n_samples
            Training data, includes reaction's containers
        y : array-like, of length n_samples
            The target variable for supervised learning problems.
        groups : array-like, with shape (n_samples,)
            Group labels for the samples used while splitting the dataset into
            train/test set.
        Yields
        ------
        train : ndarray
            The training set indices for that split.
        test : ndarray
            The testing set indices for that split.