Esempio n. 1
0
 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)
Esempio n. 2
0
 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__
Esempio n. 3
0
 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__
Esempio n. 4
0
 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)
Esempio n. 5
0
 def test_empty_iterable(self):
     from flowy import parallel_reduce
     f = lambda x, y: 1
     self.assertRaises(ValueError, lambda: parallel_reduce(f, []))
Esempio n. 6
0
 def test_empty_iterable(self):
     from flowy import parallel_reduce
     f = lambda x, y: 1
     self.assertRaises(ValueError, lambda: parallel_reduce(f, []))
Esempio n. 7
0
 def __call__(self, n, r=True):
     if r:
         return restart(n, r=False)
     return parallel_reduce(self.r, map(self.m, range(n + 1)))
Esempio n. 8
0
 def __call__(self):
     a = self.task()
     return parallel_reduce(self.red, (a, 'a', 'b', 'c'))
Esempio n. 9
0
 def __call__(self):
     a = self.task()
     b = self.task()
     c = self.task()
     return parallel_reduce(self.red, (a, b, c))
Esempio n. 10
0
 def __call__(self, n, r=True):
     if r:
         return restart(n, r=False)
     return parallel_reduce(self.r, map(self.m, range(n + 1)))