JuliaArrays / ShiftedArrays.jl

Lazy shifted arrays for data analysis in Julia
Other
50 stars 10 forks source link

remove unnecessary nesting #53

Closed piever closed 2 years ago

piever commented 2 years ago

Fix #50. This actually takes the slightly more radical approach of avoiding nesting whenever possible from the constructor.

Other than the more efficient storage, there is a small difference in behavior in that now lag(v, 1) (if v is a ShiftedArray) respects the default value of v. So for instance

julia> using ShiftedArrays

julia> v = ShiftedVector(rand(3), 1, default = NaN)
3-element ShiftedVector{Float64, Float64, Vector{Float64}}:
 NaN
   0.41510884185926944
   0.3917724425282777

julia> lag(v, 1)
3-element ShiftedVector{Float64, Float64, Vector{Float64}}:
 NaN
 NaN
   0.41510884185926944

which IMO is more reasonable than returning something with values [missing, NaN, 0.41510884185926944], but I think deserves some discussion.

TODO: