예제 #1
0
    def test_parmap(self):
        def func(a):
            return a

        input_params = [(1, )]
        result = parmap(func, input_params, 1)
        self.assertEquals([1], result)
예제 #2
0
def build_board_permutations(rows, columns, used_pieces, nprocs):
    """
    Build all the board permutations in parallel.

    :param rows:
    :param columns:
    :param used_pieces:
    :param nprocs:
    :return:
    """
    permutations = build_permutations(used_pieces)

    progress_bar = ProgressBar(maxval=len(permutations),
                               widgets=[Bar(), AdaptiveETA()]).start()
    board_set = set()
    parallel_args = [(rows, columns, perm) for perm in permutations]
    built_boards = parmap(build_boards, parallel_args, nprocs, progress_bar)
    for board in built_boards:
        board_set.update(board)
    progress_bar.finish()
    return board_set
예제 #3
0
def build_board_permutations(rows, columns, used_pieces, nprocs):
    """
    Build all the board permutations in parallel.

    :param rows:
    :param columns:
    :param used_pieces:
    :param nprocs:
    :return:
    """
    permutations = build_permutations(used_pieces)

    progress_bar = ProgressBar(maxval=len(permutations),
                               widgets=[Bar(), AdaptiveETA()]).start()
    board_set = set()
    parallel_args = [(rows, columns, perm) for perm in permutations]
    built_boards = parmap(build_boards, parallel_args, nprocs, progress_bar)
    for board in built_boards:
        board_set.update(board)
    progress_bar.finish()
    return board_set
예제 #4
0
 def test_parmap(self):
     def func(a):
         return a
     input_params = [(1,)]
     result = parmap(func, input_params, 1)
     self.assertEquals([1], result)