def test(): # Create stream x and give it names 'x'. x = StreamArray('input') # v is the stream returned by stream_cumulative(x) and v = stream_cumulative(x) # avg is the stream returned by stream_average(x) avg = stream_average(x) # Give names to streams. This is helpful in reading output. v.set_name('cumulative sum of input') avg.set_name('average of input') check(v, [3.0, 8.0, 18.0, 20.0, 25.0, 36.0]) check(avg, [3.0, 4.0, 6.0, 5.0, 5.0, 6.0]) print print 'add values [3, 5, 10] to the tail of the input stream.' # Add values to the tail of stream x. x.extend([3, 5, 10]) # Print the N most recent values of streams x, v, w. x.print_recent() v.print_recent() avg.print_recent() print print 'add values [2, 5, 11] to the tail of the input stream.' # Add more values to the tail of stream x. x.extend([2, 5, 11]) # Print the N most recent values of streams x, v, w. x.print_recent() v.print_recent() avg.print_recent() check_empty()