IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python function

find_contiguous_ranges

find_contiguous_ranges()​

max.support.image.find_contiguous_ranges(arr, targets)

source

Find the contiguous ranges of the given tokens in a 1D array.

For example:

find_contiguous_ranges([1, 2, 99, 99, 3, 99, 98, 99], [98, 99])

Parameters:

Returns:

A list of (start, end) half-open ranges [start, end), one per maximal run of positions where arr holds a value in targets.

Raises:

ValueError – If arr is not 1D.

Return type:

list[tuple[int, int]]