run_lengths

daart.eval.run_lengths(array: ndarray) dict[source]

Compute distribution of run lengths for an array with integer entries.

Parameters:

array (array-like) – single-dimensional array

Returns:

keys are integer values up to max value in array, values are lists of run lengths

Return type:

dict

Example

>>> a = [1, 1, 1, 0, 0, 4, 4, 4, 4, 4, 4, 0, 1, 1, 1, 1]
>>> run_lengths(a)
{0: [2, 1], 1: [3, 4], 2: [], 3: [], 4: [6]}