diff --git a/src/awkward/operations/ak_run_lengths.py b/src/awkward/operations/ak_run_lengths.py index 2cbb192d25..fbe7dea580 100644 --- a/src/awkward/operations/ak_run_lengths.py +++ b/src/awkward/operations/ak_run_lengths.py @@ -115,7 +115,7 @@ def lengths_of(data, offsets): # To consider only the interior boundaries, we ignore the start and end # offset values. These can be repeated with empty sublists, so we mask them out. is_interior = backend.nplike.logical_and( - 0 < offsets, offsets < len(data) - 1 + 0 < offsets, offsets < len(data) ) interior_offsets = offsets[is_interior] diffs[interior_offsets - 1] = True diff --git a/tests/test_0733_run_lengths.py b/tests/test_0733_run_lengths.py index 85ef054bd1..ab6471a685 100644 --- a/tests/test_0733_run_lengths.py +++ b/tests/test_0733_run_lengths.py @@ -21,6 +21,17 @@ def test(): ] +def test_all_same(): + array = ak.Array([[3, 3, 3, 3], [3], [], [3, 3, 3], [3]]) + assert ak.operations.run_lengths(array).to_list() == [ + [4], + [1], + [], + [3], + [1], + ] + + def test_groupby(): array = ak.Array( [