Esempio n. 1
0
def test_distribution_pid_of_index_with_empty_3():
    # pylint: disable=missing-docstring
    value = random.randint(0, 100)
    distr = Distribution([0, 10, 0, 20])
    res = distr.to_pid(10, value)
    exp = 3, (10, value)
    assert exp == res
Esempio n. 2
0
def test_distribution_pid_of_index_3():
    # pylint: disable=missing-docstring
    value = random.randint(0, 100)
    distr = Distribution([4, 12, 27, 18])
    res = distr.to_pid(43, value)
    exp = 3, (43, value)
    assert exp == res
Esempio n. 3
0
 def permute(self: 'PList[T]', bij: Callable[[int], int]) -> 'PList[T]':
     p_list = self.__get_shape()
     distr = Distribution(self.__distribution)
     new_indices = self.mapi(lambda i, x: distr.to_pid(bij(i), x)
                             ).get_partition().map(_group_by)
     mapping = new_indices.__content[0]
     keys = mapping.keys()
     messages = [mapping[pid] if pid in keys else [] for pid in par.procs()]
     exchanged = SList(parimpl.COMM.alltoall(messages)).flatten()
     exchanged.sort()
     p_list.__content = exchanged.map(lambda pair: pair[1])
     return p_list