<commit_before># -*- coding: utf-8 -*-
# pylint: disable=
"""
Created on Tue May  3 18:34:45 2016

@author: <NAME> and <NAME>
"""

import random
import objects

def mating_pool(population, num_of_children=10):
    pool = []
    # Sort the population
    sorted_population = sorted(population, objects.Invader.compare_fitness)
    # Get the maximum fitness
    max_fitness = sorted_population[-1].steps
    while len(pool) < num_of_children*2:
        # Generate a random uniform number between [0, max_fitness]
        r = random.uniform(0, max_fitness)
        # Select the one according to the accumulative probability
        for i in population:
            if i.steps >= r:
                pool.append(i)
                break

    random.shuffle(pool)
    return pool<commit_msg>changed mating_pool to return a list of pairs<commit_after># -*- coding: utf-8 -*-
# pylint: disable=
"""
Created on Tue May  3 18:34:45 2016

@author: <NAME> and <NAME>
"""

import random
import objects

def mating_pool(population, num_of_children=10):
    pool = []
    # Sort the population
    sorted_population = sorted(population, objects.Invader.compare_fitness)
    # Get the maximum fitness
    max_fitness = sorted_population[-1].steps
    while len(pool) < num_of_children*2:
        # Generate a random uniform number between [0, max_fitness]
        r = random.uniform(0, max_fitness)
        # Select the one according to the accumulative probability
        for i in population:
            if i.steps >= r:
                pool.append(i)
                break

    random.shuffle(pool)
    return [(pool[i], pool[i+1]) for i in xrange(0, len(pool), 2)]
{'fraction_non_alphanumeric': 0.10163339382940109, 'fraction_numerical': 0.023593466424682397, 'mean_word_length': 2.7848970251716247, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7266140', 'n_tokens_mistral': 531, 'n_tokens_neox': 491, 'n_words': 153}