def partition(ls, ls_size):
    """Partitions list into a list of lists.

    Useful for dividing up a population into batches in order to
    process each batch in a different process.

    :param ls: list to be partitioned.
    :param ls_size: length of sublist.
    :return: partitioned list
    """
    parition_num = int(len(ls) / ls_size) + 1
    return [ls[i * ls_size:(i + 1) * ls_size] for i in range(parition_num)]