def __call__(self, time_scale=1): reduce_f = lambda x, y: self.a( x, y, sleep=1.5 * time_scale, identity='reduce %s %s' % (x, y)) t = map(lambda x: x * time_scale, [0.5, 1.5, 1.0, 6.0, 5.0, 2.0]) map_f = lambda x, sleep: self.a(x, sleep=sleep, identity='map %s' % x) results = map(map_f, range(1, 7), t) return parallel_reduce(reduce_f, results)
def test_one_element_iterable(self): from flowy import parallel_reduce f = lambda x, y: 1 x = object() parallel_x = parallel_reduce(f, [x]) # python 2.6 doesn't have assertIs assert x is parallel_x.__wrapped__
def __call__(self, time_scale=1): reduce_f = lambda x, y: self.a(x, y, sleep=1.5 * time_scale, identity='reduce %s %s' % (x, y)) t = map(lambda x: x * time_scale, [0.5, 1.5, 1.0, 6.0, 5.0, 2.0]) map_f = lambda x, sleep: self.a(x, sleep=sleep, identity='map %s' % x) results = map(map_f, range(1, 7), t) return parallel_reduce(reduce_f, results)
def test_empty_iterable(self): from flowy import parallel_reduce f = lambda x, y: 1 self.assertRaises(ValueError, lambda: parallel_reduce(f, []))
def __call__(self, n, r=True): if r: return restart(n, r=False) return parallel_reduce(self.r, map(self.m, range(n + 1)))
def __call__(self): a = self.task() return parallel_reduce(self.red, (a, 'a', 'b', 'c'))
def __call__(self): a = self.task() b = self.task() c = self.task() return parallel_reduce(self.red, (a, b, c))