示例#1
0
文件: examples.py 项目: xethorn/flowy
 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)
示例#2
0
文件: test_swf.py 项目: xethorn/flowy
 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__
示例#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__
示例#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)
示例#5
0
 def test_empty_iterable(self):
     from flowy import parallel_reduce
     f = lambda x, y: 1
     self.assertRaises(ValueError, lambda: parallel_reduce(f, []))
示例#6
0
文件: test_swf.py 项目: xethorn/flowy
 def test_empty_iterable(self):
     from flowy import parallel_reduce
     f = lambda x, y: 1
     self.assertRaises(ValueError, lambda: parallel_reduce(f, []))
示例#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)))
示例#8
0
 def __call__(self):
     a = self.task()
     return parallel_reduce(self.red, (a, 'a', 'b', 'c'))
示例#9
0
 def __call__(self):
     a = self.task()
     b = self.task()
     c = self.task()
     return parallel_reduce(self.red, (a, b, c))
示例#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)))