Skip to content

← programming package

WindowedIterator

An iterator that emits windows of items from the original iterable.

The windows will be lists of at most max_length items. If the step size is not set, the windows will be consecutive. It is possible for the windows to not evenly divide the input sequence's length, in which case by default the last window will be shorter, unless the padding option is set to a value other than no padding, in which case the emitted windows will be padded to the desired length. If consecutive windows are used, one may use the balanced option to balance the windows in length such that the last window does not have many fewer items than the others. Version 1.0.0

Ports/Properties

iterable

Data to iterate over.

  • verbose name: Iterable
  • default value: None
  • port type: DataPort
  • value type: object (can be None)
  • data direction: IN

curitem

Current batch.

  • verbose name: Curitem
  • default value: None
  • port type: DataPort
  • value type: list (can be None)
  • data direction: OUT

max_length

Maximum length of the emitted windows.

  • verbose name: Max Length
  • default value: 3
  • port type: IntPort
  • value type: int (can be None)

step

Step size between successive windows. The default is consecutive (i.e., non-overlapping) windows.

  • verbose name: Step
  • default value: None
  • port type: IntPort
  • value type: int (can be None)

padding

Padding to use when windows would be shorter than the desired length. If set to no padding, then the emitted windows can be shorter than the desired length.

  • verbose name: Padding
  • default value: (no padding)
  • port type: Port
  • value type: object (can be None)

balanced

If enabled, the batches will be balanced in length if the iterable's length is not divisible by the max length. This can only be used with consecutive windows, i.e., when step is not set.

  • verbose name: Balanced
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

  • verbose name: Set Breakpoint (Debug Only)
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

  • verbose name: Metadata
  • default value: {}
  • port type: DictPort
  • value type: dict (can be None)

verbose

Whether to print the current item to the console.

  • verbose name: Verbose
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)