本文整理汇总了Python中pipeline.Pipeline.stream方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.stream方法的具体用法?Python Pipeline.stream怎么用?Python Pipeline.stream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pipeline.Pipeline
的用法示例。
在下文中一共展示了Pipeline.stream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_when_consumer_yield_none
# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import stream [as 别名]
def test_when_consumer_yield_none(self):
pipeline = Pipeline().add(
PipeBuilder().alias("yield_none").consumer(lambda m: m if m == 0 else None).buffer_size(100).number_of_consumer(2)
)
expected = [0]
actual = [x for x in pipeline.stream(range(100))]
self.assertEquals(expected, actual)
示例2: test_one_pipe
# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import stream [as 别名]
def test_one_pipe(self):
pipeline = Pipeline().add(
PipeBuilder().alias("multiplier").consumer(lambda m: m * m).buffer_size(100).number_of_consumer(10)
)
expected = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
actual = [x for x in pipeline.stream(range(10))]
actual.sort()
self.assertEquals(expected, actual)
示例3: test_multiple_pipes
# 需要导入模块: from pipeline import Pipeline [as 别名]
# 或者: from pipeline.Pipeline import stream [as 别名]
def test_multiple_pipes(self):
pipeline = Pipeline().add(
PipeBuilder("aggregator").aggregation_size(2).buffer_size(10)
).add(
PipeBuilder("summation").consumer(lambda aggr: sum(aggr)).number_of_consumer(1).buffer_size(10)
).add(
PipeBuilder("nth_triangular").consumer(lambda n: (n * n + n) / 2).number_of_consumer(1).buffer_size(10)
)
expect = [1, 15, 45, 91]
self.assertEquals(expect, [x for x in pipeline.stream(range(8))])