Skip to content

Commit ebba102

Browse files
committed
fix longest_run_of_true when the run is at the end
1 parent 3bb39c1 commit ebba102

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/numerical_algorithms.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ end
229229
The slice corresponding to the longest run of `true`s in the vector `x`.
230230
"""
231231
function longest_run_of_trues(x)
232-
next_true = findnext.(Ref(.!x), eachindex(x))
233-
next_true[isnothing.(next_true)] .= 0
232+
nothing2length(y) = isnothing(y) ? length(x) : y
233+
next_true = nothing2length.(findnext.(Ref(.!x), eachindex(x)))
234234
(len,start) = findmax(next_true .- eachindex(x))
235235
start:start+len
236236
end

0 commit comments

Comments
 (0)