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


Python Stream.append方法代码示例

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


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

示例1: main

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import append [as 别名]
def main():
    x = Stream('x')
    y = Stream('y')
    z = Stream('z')
    print_stream(x)
    print_stream(y)
    print_stream(z)
    
    timed_merge_agent([x,y], z)

    x.extend([(1, 'a'), (3, 'b'), (3, 'c'), (10, 'd'), (15, 'e'), (17, 'f')])
    y.extend([(2, 'A'), (3, 'B'), (3, 'C'), (9, 'D'), (20, 'E')])

    t = Stream('t')
    u = Stream('u')
    v = Stream('v')
    w = Stream('w')
    print_stream(t)
    print_stream(u)
    print_stream(v)
    print_stream(w)
    
    timed_merge_agent([u,v], w, call_streams=[t])

    u.extend([(1, 'a'), (3, 'b'), (3, 'c'), (10, 'd'), (15, 'e'), (17, 'f')])
    v.extend([(2, 'A'), (3, 'B'), (3, 'C'), (9, 'D'), (20, 'E')])
    t.append(0)
    u.extend([(21, 'g'), (23, 'h'), (33, 'i'), (40, 'j'), (50, 'K')])
    v.extend([(22, 'F'), (23, 'G'), (43, 'H'), (51, 'I'), (59, 'J')])
    t.append(0)
开发者ID:StreamPy,项目名称:StreamPy,代码行数:32,代码来源:TimedMerge.py

示例2: ef

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import append [as 别名]
ef(x, y, np.sin, call_streams=[trigger_1])
# Create an agent that puts the clipped elements of x
# into z where values below a_min are set to a_min and
# values above a_max are set to a_max. This agent
# executes when elements appear in stream trigger_2.
# This agent remains asleep until woken up by new elements
# in trigger_2.
ef(x, z, np.clip, call_streams=[trigger_2], a_min=2, a_max=8)

# Put elements 0, 1, 2, 3, 4 into stream, x.
# The agents only process elements in x when their trigger
# streams have new values.
x.extend(range(5))
# Wake up the agent that puts values into y.
# Now y has 5 values: sine(0),... , sine(4)
trigger_1.append(1)
# Wake up the agent that puts values into z.
# Now z has 5 values: clip(0, 2, 8).... clip(4, 2, 8)
trigger_2.append(1)

# Put elements 5, 6, 7, 8, 9 into stream x.
x.extend(range(5, 10))
# Now x has 10 values 0, ..., 9 whereas y and z each
# have 5 values.
# Do NOT wake up the agent that puts values into y, but do
# wake up the agent that puts values into z.
trigger_2.append(2)
# Now z has 10 values: clip(0, 2, 8).... clip(9, 2, 8)
# because the clip agents was woken up by trigger 2, and
# the agent processed the messages 5, ..., 9 waiting for it
# and it put 5 values into z.
开发者ID:StreamPy,项目名称:StreamPy,代码行数:33,代码来源:tutorial_call_streams.py

示例3: return

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import append [as 别名]
    print 'std/avg = ', std/avg, 'window_size = ', window_size
    return ([avg, std], window_size, step_size)

initial_window_size = 6
initial_step_size = 6

awf([u,v], [y,z], h, initial_window_size, initial_step_size,
    call_streams=[a], ratio=0.6, min_window_size=4)

u.extend([randint(0, 20) for _ in range(15)])
v.extend([randint(0, 20) for _ in range(15)])
print 'UNPROCESSED INPUT \n'
# Agent does not execute though it has unprocessed input.

u.extend([randint(0, 20) for _ in range(15)])
v.extend([randint(0, 20) for _ in range(15)])
print 'MORE UNPROCESSED INPUT \n'
print 'INPUT IS PROCESSED WHEN VALUE APPEARS IN CALL STREAM.'
a.append(1)
# Agent processes unprocessed input.

u.extend([randint(0, 20) for _ in range(15)])
v.extend([randint(0, 20) for _ in range(15)])
print '\n MORE UNPROCESSED INPUT \n'
# Agent does not execute though it has unprocessed input.
print 'INPUT IS PROCESSED WHEN NEXT VALUE APPEARS IN CALL STREAM.'
a.append(2)
# Agent processes unprocessed input.

开发者ID:StreamPy,项目名称:StreamPy,代码行数:30,代码来源:tutorial_adjustable_window_multi_in_multi_out.py

示例4: Stream

# 需要导入模块: from Stream import Stream [as 别名]
# 或者: from Stream.Stream import append [as 别名]
        window_size=window_size,
        step_size=step_size)

# Create and name the input streams of the function.
l_stream = Stream('l stream')
m_stream = Stream('m stream')

# The function returns a list of two streams.
inrange_exp_smooth_stream, outlier_exp_smooth_stream = \
  inrange_and_outlier_streams(
      list_of_two_streams=[l_stream, m_stream],
      window_size=20,
      step_size=20,
      alpha=0.9,
      threshold=1)

# Give names to the output streams and print them.
inrange_exp_smooth_stream.set_name('inrange exp smooth')
outlier_exp_smooth_stream.set_name('outlier exp smooth')
print_stream(inrange_exp_smooth_stream)
print_stream(outlier_exp_smooth_stream)

# Drive the example.
# Add values to input streams l_stream and m_stream.
# Most of the output values should be in range because they
# are uniform random numbers in the interval (0.0, 1.0).
for _ in range(100):
    x = random.random()
    l_stream.append(x)
    m_stream.append(x+0.01*random.random())
开发者ID:StreamPy,项目名称:StreamPy,代码行数:32,代码来源:examples_window_wrapper.py


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