JuliaDynamics / TransitionsInTimeseries.jl

Transition Indicators / Early Warning Signals / Regime Shifts / Change Point Detection
MIT License
18 stars 5 forks source link

definition of equispaced_step for OffsetArray errors #78

Closed felixcremer closed 3 months ago

felixcremer commented 3 months ago

I am going through the untested functions in codecov and the definition of equispaced_step looks wrong for me for OffsetVectors and it throws an error:

using OffsetArrays, TransitionsInTimeseries

julia> a = OffsetVector([-4, 2:10...], -1:8)
julia> equispaced_step(a)
ERROR: BoundsError: attempt to access 10-element OffsetArray(::Vector{Int64}, -1:8) with eltype Int64 with indices -1:8 at index [9]
Stacktrace:
 [1] throw_boundserror(A::OffsetVector{Int64, Vector{Int64}}, I::Tuple{Int64})
   @ Base ./abstractarray.jl:737
 [2] checkbounds
   @ ./abstractarray.jl:702 [inlined]
 [3] getindex
   @ ~/.julia/packages/OffsetArrays/E3eDu/src/OffsetArrays.jl:437 [inlined]
 [4] equispaced_step(t::OffsetVector{Int64, Vector{Int64}})
   @ TransitionsInTimeseries ~/.julia/packages/TransitionsInTimeseries/XwpWT/src/misc/timeseries.jl:24
 [5] top-level scope
   @ REPL[9]:1

Also this function should be tested.

This is part of the JOSS review openjournals/joss-reviews#6464