pyufunc.iter_split_when#

pyufunc.iter_split_when(iterable, predicate, *, maxsplit=-1)#

Split an iterable when a pair-wise predicate is true.

Parameters:
  • iterable – Iterable to split.

  • predicate – Function called with adjacent items.

  • maxsplit – Maximum number of splits. Use -1 for no limit.

Note

Example

>>> list(iter_split_when([1, 2, 5], lambda a, b: b - a > 1))
[[1, 2], [5]]
Returns:

Split groups from more_itertools.split_when.

Return type:

Iterable[list[Any]]