Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slicing to ContResult #189

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/PlotsExt/RecipesPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RecipesBase.@recipe function Plots(contres::AbstractBranchResult;
end

# display bifurcation points
bifpt = filter(x -> (x.type != :none) && (x.type != :endpoint) && (plotfold || x.type != :fold) && (x.idx <= length(contres)-1), contres.specialpoint)
bifpt = filter(x -> (x.type != :none) && (x.type != :endpoint) && (plotfold || x.type != :fold) && (x.idx <= length(contres)), contres.specialpoint)

if length(bifpt) >= 1 && plotspecialpoints #&& (ind1 == :param)
if filterspecialpoints == true
Expand Down
39 changes: 33 additions & 6 deletions src/Results.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,31 @@ setparam(br::AbstractBranchResult, p0) = setparam(br.prob, p0)
Base.getindex(br::ContResult, k::Int) = (br.branch[k]..., eigenvals = haseigenvalues(br) ? br.eig[k].eigenvals : nothing, eigenvecs = haseigenvector(br) ? br.eig[k].eigenvecs : nothing)
Base.lastindex(br::ContResult) = length(br)

function Base.getindex(br0::ContResult, k::UnitRange)
br = deepcopy(br0)

if ~isnothing(br.branch)
@reset br.branch = StructArray([setproperties(pt; step=pt.step + 1 - k[1]) for pt in br.branch[k]])
end

if ~isnothing(br.eig)
@reset br.eig = [setproperties(pt; step=pt.step + 1 - k[1]) for pt in br.eig[k]]
end

if ~isnothing(br.sol)
@reset br.sol = [setproperties(pt; step=pt.step + 1 - k[1]) for pt in br.sol[k]]
end

if ~isnothing(br.specialpoint)
@reset br.specialpoint = [
setproperties(pt; step=pt.step + 1 - k[1], idx=pt.idx + 1 - k[1])
for pt in br.specialpoint if pt.idx in k
]
end

return br
end

"""
$(SIGNATURES)

Expand Down Expand Up @@ -236,12 +261,12 @@ Function is used to initialize the composite type `ContResult` according to the
- `lens`: lens to specify the continuation parameter
- `eiginfo`: eigen-elements (eigvals, eigvecs)
"""
function _contresult(iter,
state,
printsol,
br,
x0,
contParams::ContinuationPar{T, S, E}) where {T, S, E}
function _contresult(iter,
state,
printsol,
br,
x0,
contParams::ContinuationPar{T, S, E}) where {T, S, E}
# example of bifurcation point
bif0 = SpecialPoint(x0, state.τ, T, namedprintsol(printsol))
# save full solution?
Expand Down Expand Up @@ -306,6 +331,8 @@ Base.lastindex(br::Branch) = lastindex(br.γ)
# for example, it allows to use the plot recipe for ContResult as is
Base.getproperty(br::Branch, s::Symbol) = s in (:γ, :bp) ? getfield(br, s) : getproperty(br.γ, s)
Base.getindex(br::Branch, k::Int) = getindex(br.γ, k)
Base.getindex(br::Branch, k::UnitRange) = setproperties(br; γ = getindex(br.γ, k))

####################################################################################################
_reverse!(x) = reverse!(x)
_reverse!(::Nothing) = nothing
Expand Down