Skip to content

Commit

Permalink
trendline algo bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
dysonance committed Apr 6, 2021
1 parent 30c038d commit be648f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/trendy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function maxima(x::Array{T}; threshold::T=0.0, order::Int=1) where {T<:Real}
end
while order > 1
idx = findall(crit)
crit[idx[!maxima(x[crit], threshold=threshold)]] .= false
crit[idx[.!maxima(x[crit], threshold=threshold)]] .= false
order -= 1
end
return crit
Expand All @@ -44,7 +44,7 @@ function minima(x::Array{T}; threshold::T=0.0, order::Int=1) where {T<:Real}
end
while order > 1
idx = findall(crit)
crit[idx[!minima(x[crit], threshold=threshold)]] .= false
crit[idx[.!minima(x[crit], threshold=threshold)]] .= false
order -= 1
end
return crit
Expand All @@ -71,7 +71,7 @@ function resistance(x::Array{T}; order::Int=1, threshold::T=0.0) where {T<:Real}
out[.!crit] .= NaN
idx = findall(crit)
@inbounds for i=2:length(idx)
out[idx[i-1]:idx[i]] .= interpolate(idx[i-1], idx[i], x[i-1], x[i])
out[idx[i-1]:idx[i]] .= interpolate(idx[i-1], idx[i], x[idx[i-1]], x[idx[i]])
end
return out
end
Expand All @@ -89,7 +89,7 @@ function support(x::Array{T}; order::Int=1, threshold::T=0.0) where {T<:Real}
out[.!crit] .= NaN
idx = findall(crit)
@inbounds for i=2:length(idx)
out[idx[i-1]:idx[i]] .= interpolate(idx[i-1], idx[i], x[i-1], x[i])
out[idx[i-1]:idx[i]] .= interpolate(idx[i-1], idx[i], x[idx[i-1]], x[idx[i]])
end
return out
end

0 comments on commit be648f3

Please sign in to comment.