Exemplo n.º 1
0
def parallelize_pts_custom(pt_list, popt_list):
    if len(pt_list) != len(popt_list):
        raise Exception(
            'pt_list or popt_list malformed. Length does not match.')

    ts = TaskSet()
    for i in range(len(pt_list)):
        ts.merge_ts(pt_list[i][popt_list[i]])

    return ts
    def test_ts_merge(self):
        param1 = {'id': 2}
        t1 = Task(**param1)
        param2 = {'id': 3}
        t2 = Task(**param2)

        ts1 = TaskSet()
        ts2 = TaskSet()
        ts1.append(t1)
        ts2.append(t1)
        ts2.append(t2)

        ts1.merge_ts(ts2)
        self.assertEqual(len(ts1), 3)

        self.assertEqual(ts1[2], t2)
Exemplo n.º 3
0
def parallelize_pts_max(pt_list, **kwargs):
    max_opt = kwargs.get('max_option', 1)
    ts = TaskSet()
    for pt in pt_list:
        ts.merge_ts(pt[max_opt])
    return ts
Exemplo n.º 4
0
def parallelize_pts_random(pt_list, **kwargs):
    max_opt = kwargs.get('max_option', 1)
    ts = TaskSet()
    for pt in pt_list:
        ts.merge_ts(pt[random.randint(1, max_opt)])
    return ts
Exemplo n.º 5
0
def parallelize_pts_single(pt_list):
    ts = TaskSet()
    for pt in pt_list:
        ts.merge_ts(pt[1])
    return ts