function sliding_window

deeptime.util.data.sliding_window(seq, radius=1, fixed_width=False)

Creates a generator that yields exactly len(seq) subsequences of length at most 2 * radius + 1 in a sliding window manner along the given sequence. If fixed_width=True, the tuples will always have width 2*”width”+1.

Parameters:
  • seq (iterable object) – The sequence.

  • radius (int, default=1) – The sliding window radius

  • fixed_width (bool, default=False) – If set to True, this generator yields tuples that are guaranteed to have length 2 * radius + 1

Returns:

sliding_window – A generator object yielding sliding windows along the provided sequence.

Return type:

generator