当前位置: 首页>>代码示例>>Python>>正文


Python Stream.close方法代码示例

本文整理汇总了Python中Stream.Stream.close方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.close方法的具体用法?Python Stream.close怎么用?Python Stream.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stream.Stream的用法示例。


在下文中一共展示了Stream.close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import close [as 别名]
def test():
    

    # Create stream x, and give it name 'input'.
    x = Stream('input')

    # u is the stream returned by stream_square(x)  and
    # v is the stream returned by stream_double(x)
    # w is the stream returned by stream_square(v) and
    #   so w could have been defined as:
    #   stream_square(stream_double(x))
    # a is the stream containing only even values of x
    #   Function even(v) may return _no_value, but
    #   _no_value is not inserted into the stream.
    #   Thus even(v) acts like a filter.
    print_stream(x)
    r = square_elements_in_stream(x)
    u = stream_square(x)
    v = stream_double(x)
    w = stream_square(v)
    a = stream_even(x)
    b = multiply_elements_in_stream(stream=x, multiplier=3)
    c = boolean_of_values_greater_than_threshold(
        stream=x, threshold=4)
    

    # Give names to streams u, v, and w. This is helpful in reading output.
    r.set_name('r: square of input')
    u.set_name('u: square of input')
    v.set_name('double of input')
    w.set_name('square of double of input')
    a.set_name('even values in input')
    b.set_name('multiply values in input')
    c.set_name('booleans where value exceeds threshold')

    check(r, [9, 25, 4, 36])
    check(u, [9, 25, 4, 36])
    check(v, [6, 10, 4, 12])
    check(w, [36, 100, 16, 144])
    check(a, [2, 6])
    check(b, [9, 15, 6, 18])
    check(c, [False, True, False, True])

    print
    print 'add [3, 5] to the tail of the input stream'
    # Add values to the tail of stream x.
    x.extend([3, 5])

    # Print the N most recent values of streams x, u, v, w.
    x.print_recent()
    r.print_recent()
    u.print_recent()
    v.print_recent()
    w.print_recent()
    a.print_recent()
    b.print_recent()
    c.print_recent()

    print
    print 'add [2, 6] to the tail of the input stream'
    # Add more values to the tail of stream x.
    x.extend([2, 6])

    # Print the N most recent values of streams x, u, v, w.
    x.print_recent()
    r.print_recent()
    u.print_recent()
    v.print_recent()
    w.print_recent()
    a.print_recent()
    b.print_recent()
    c.print_recent()

    x.close()
    r.close()
    u.close()

    check_empty()
开发者ID:alphaz99,项目名称:stream-ml-py,代码行数:80,代码来源:test_example_element_single_in_single_out_stateless.py


注:本文中的Stream.Stream.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。