warp.utils.runlength_encode#
- warp.utils.runlength_encode(
- values,
- run_values,
- run_lengths,
- run_count=None,
- value_count=None,
Perform run-length encoding on an array.
This function compresses an array by replacing consecutive identical values with a single value and its count. For example,
[1,1,1,2,2,3]becomesvalues=[1,2,3]andlengths=[3,2,1].- Parameters:
values (array) – Input array to encode. Must be of type
int32.run_values (array) – Output array to store unique values. Must be at least value_count in size.
run_lengths (array) – Output array to store run lengths. Must be at least value_count in size.
run_count (array | None) – Optional output array to store the number of runs. If
None, returns the count as an integer.value_count (int | None) – Number of values to process. If
None, processes entire array.
- Returns:
Number of runs if
run_countisNone, otherwise returns therun_countarray.- Raises:
RuntimeError – If array storage devices don’t match, if storage size is insufficient, or if data types are unsupported.
- Return type: