Home | Trees | Indices | Help |
|
---|
|
window PREDICATE
window -o WINDOW_SIZE
window -d WINDOW_SIZE
Groups of consecutive input objects are formed into tuples which are passed to the output stream. The objects are grouped in one of two mechanisms.
1) A new group is started on the first input object, and for any
subsequent object for which PREDICATE
returns true. For
example, if the input stream contains the integers 1, 2, 3,
...
, then:
window 'n: n % 3 == 2'
yields as output:
((1,),) ((2,), (3,), (4,)) ((5,), (6,), (7,)) ((8,), (9,), (10,)) ...
I.e., a new tuple is started for each integer n such that n % 3 = 2.
2) Groups have a fixed number of objects. The -o
and
-d
flags specify WINDOW_SIZE
, the number of
objects in the groups. -o
specifies overlapping
windows, in which each input object begins a new list containing
WINDOW_SIZE
items. Groups may be padded with
None
values to ensure that the group's size is
WINDOW_SIZE
.
Example: For input 0, 1, ..., 9
, window -o
3
yields these tuples:
((0,), (1,), (2,)) ((1,), (2,), (3,)) ((2,), (3,), (4,)) ((3,), (4,), (5,)) ((4,), (5,), (6,)) ((5,), (6,), (7,)) ((6,), (7,), (8,)) ((7,), (8,), (9,)) ((8,), (9,), (None,)) ((9,), (None,), (None,))
-d
specifies disjoint windows, in which each input
object appears in only one group. A new group is started every
WINDOW_SIZE
objects. The last window may be padded with
(None,) to ensure that it has WINDOW_SIZE
elements.
Example: For input 0, 1, ..., 9
, window -d
3
yields these tuples:
((0,), (1,), (2,)) ((3,), (4,), (5,)) ((6,), (7,), (8,)) ((9,), (None,), (None,))
Functions | |||
|
Function Details |
Groups of consecutive input objects are formed into tuples which are
passed to the output stream. Only one of |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Oct 3 15:23:48 2010 | http://epydoc.sourceforge.net |