You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm using the package primarily for its moving averages. I found that pretty much every single case uses the wrong loop order for best performance. The fix is pretty easy, ie just swap the inner and outer loops. For example, this function in movingaverages.jl.
functionsma(ta::TimeArray, n::Integer)
tstamps =timestamp(ta)[n:end]
vals =zeros(size(values(ta),1) - (n-1), size(values(ta),2))
for i in1:size(values(ta),1) - (n-1)
for j in1:size(values(ta),2)
vals[i,j] =nanmean(values(ta)[i:i+(n-1),j])[1]
endend
cname = Symbol[]
cols =colnames(ta)
for c in1:length(cols)
push!(cname, Symbol(string(cols[c], "_sma_", n)))
endTimeArray(tstamps, vals, cname, meta(ta))
end
would simply turn into
functionsma(ta::TimeArray, n::Integer)
tstamps =timestamp(ta)[n:end]
vals =zeros(size(values(ta),1) - (n-1), size(values(ta),2))
for j in1:size(values(ta),2)
for i in1:size(values(ta),1) - (n-1)
vals[i,j] =nanmean(values(ta)[i:i+(n-1),j])[1]
endend
cname = Symbol[]
cols =colnames(ta)
for c in1:length(cols)
push!(cname, Symbol(string(cols[c], "_sma_", n)))
endTimeArray(tstamps, vals, cname, meta(ta))
end
The text was updated successfully, but these errors were encountered:
Hi, I'm using the package primarily for its moving averages. I found that pretty much every single case uses the wrong loop order for best performance. The fix is pretty easy, ie just swap the inner and outer loops. For example, this function in
movingaverages.jl
.would simply turn into
The text was updated successfully, but these errors were encountered: