Skip to content

Commit

Permalink
Rename: special_points -> special_intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Aug 21, 2018
1 parent bf29d94 commit d398cff
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 53 deletions.
6 changes: 3 additions & 3 deletions benchmark/bench_morris_lecar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ using BenchmarkTools
using Setfield: @lens

using Bifurcations
using Bifurcations: Codim1, Codim2, special_points
using Bifurcations: Codim1, Codim2, special_intervals
using Bifurcations.Continuations: as, pre_solve!, sweep!
using Bifurcations.Codim2LimitCycle: FoldLimitCycleProblem
using Bifurcations.Examples: MorrisLecar

function make_morris_lecar_hopf_solver()
solver1 = init(MorrisLecar.make_prob())
solve!(solver1)
hopf_point, = special_points(solver1, Codim1.PointTypes.hopf)
hopf_point, = special_intervals(solver1, Codim1.PointTypes.hopf)

hopf_prob = BifurcationProblem(
hopf_point,
Expand All @@ -28,7 +28,7 @@ end
function make_morris_lecar_flc_solver()
hopf_solver = make_morris_lecar_hopf_solver()
solve!(hopf_solver)
bautin_point, = special_points(hopf_solver, Codim2.PointTypes.bautin)
bautin_point, = special_intervals(hopf_solver, Codim2.PointTypes.bautin)

flc_prob = FoldLimitCycleProblem(
bautin_point,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/calcium.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ savefig(plt, "calcium-1.png"); nothing # hide
Find the left Saddle-Node bifurcation point:

```@example calcium
using Bifurcations: special_points
using Bifurcations: special_intervals
point_list = sort!(special_points(solver), by=p->p.u0[end])
point_list = sort!(special_intervals(solver), by=p->p.u0[end])
point = point_list[1]
```

Expand Down
10 changes: 5 additions & 5 deletions docs/src/examples/morris_lecar.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Modified Morris-Lecar model from [Dhooge, Govaerts, Kuznetsov (2003)]:

```@example morris_lecar
using Bifurcations
using Bifurcations: special_points
using Bifurcations: special_intervals
using Bifurcations.Codim1
using Bifurcations.Codim2
using Bifurcations.Codim2LimitCycle: FoldLimitCycleProblem
Expand Down Expand Up @@ -43,7 +43,7 @@ savefig(plt1, "morris_lecar-1.png"); nothing # hide
### Start continuation of Hopf bifurcation

```@example morris_lecar
hopf_point, = special_points(solver, Codim1.PointTypes.hopf)
hopf_point, = special_intervals(solver, Codim1.PointTypes.hopf)
```

Solve continuation of the Hopf point:
Expand All @@ -65,7 +65,7 @@ hopf_solver1 = init(
### Start continuation of fold bifurcation of limit cycle at Bautin bifurcation

```@example morris_lecar
bautin_point, = special_points(hopf_solver1, Codim2.PointTypes.bautin)
bautin_point, = special_intervals(hopf_solver1, Codim2.PointTypes.bautin)
```

Construct a problem for fold bifurcation of the limit cycle starting
Expand Down Expand Up @@ -113,7 +113,7 @@ savefig(plt_periods, "morris_lecar-periods.png"); nothing # hide
### Start continuation of Saddle-Node bifurcation

```@example morris_lecar
sn_point, = special_points(solver, Codim1.PointTypes.saddle_node)
sn_point, = special_intervals(solver, Codim1.PointTypes.saddle_node)
```

Going back to the original continuation of the equilibrium, let's
Expand All @@ -139,7 +139,7 @@ sn_solver = init(

```@example morris_lecar
hopf_prob2 = BifurcationProblem(
special_points(sn_solver, Codim2.PointTypes.bogdanov_takens)[1],
special_intervals(sn_solver, Codim2.PointTypes.bogdanov_takens)[1],
sn_solver,
)
hopf_solver2 = init(hopf_prob2)
Expand Down
4 changes: 2 additions & 2 deletions misc/calcium.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ plot = Bifurcations.plot # workaround
plt1 = plot(sol)
display(plt1)

using Bifurcations: BifurcationProblem, special_points
using Bifurcations: BifurcationProblem, special_intervals
using Setfield: @lens

point_list = sort!(special_points(solver), by=p->p.u0[end])
point_list = sort!(special_intervals(solver), by=p->p.u0[end])
point = point_list[1]
@show point

Expand Down
4 changes: 2 additions & 2 deletions src/base/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function Base.show(io::IO, sweep::BifurcationSweep)

n_all = length(sweep)
n_sb = length(super.simple_bifurcation)
n_sp = length(sweep.special_points)
n_sp = length(sweep.special_intervals)
if get(io, :compact, false)
println(io, " ", n_sb + n_sp, "/", n_all, " special/points")
else
Expand All @@ -75,7 +75,7 @@ function show_solution_info(io::IO, sol::BifurcationSolution)
end
n_all = sum(length, super.sweeps)
n_sb = sum(length(s.simple_bifurcation) for s in super.sweeps)
n_sp = sum(length(s.special_points) for s in sol.sweeps)
n_sp = sum(length(s.special_intervals) for s in sol.sweeps)
if get(io, :compact, false)
println(io, " ", n_sb + n_sp, "/", n_all, " special/points")
else
Expand Down
2 changes: 1 addition & 1 deletion src/base/solution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct BifurcationSweep{
super::S
jacobians::Vector{JType}
eigvals::Vector{eType}
special_points::Vector{pType}
special_intervals::Vector{pType}
end
# See: [[../continuations/solution.jl::ContinuationSweep]]

Expand Down
2 changes: 1 addition & 1 deletion src/base/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function push_special_point!(sweep::BifurcationSweep,
J1,
WeakRef(sweep),
)
push!(sweep.special_points, point)
push!(sweep.special_intervals, point)
end

"""
Expand Down
20 changes: 10 additions & 10 deletions src/base/tools.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
special_points(solver::BifurcationSolver, args...) =
special_points(solver.sol, args...)
special_intervals(solver::BifurcationSolver, args...) =
special_intervals(solver.sol, args...)

special_points(sol::BifurcationSolution, args...) =
[point for sweep in sol.sweeps for point in special_points(sweep, args...)]
special_intervals(sol::BifurcationSolution, args...) =
[point for sweep in sol.sweeps for point in special_intervals(sweep, args...)]

special_points(sweep::BifurcationSweep) = sweep.special_points
special_points(sweep::BifurcationSweep, point_type::Enum) =
special_points(sweep, (point_type,))
special_points(sweep::BifurcationSweep,
special_intervals(sweep::BifurcationSweep) = sweep.special_intervals
special_intervals(sweep::BifurcationSweep, point_type::Enum) =
special_intervals(sweep, (point_type,))
special_intervals(sweep::BifurcationSweep,
point_types::NTuple{N, <:Enum}) where N =
filter(p -> p.point_type in point_types, special_points(sweep))
filter(p -> p.point_type in point_types, special_intervals(sweep))


"""
Expand All @@ -36,7 +36,7 @@ get_param_axis2(ctx) = get_param_axis(ctx, Val(2))

function count_special_points(sweep::BifurcationSweep)
counter = Dict{point_type_type(sweep), Int}()
for sp in sweep.special_points
for sp in sweep.special_intervals
counter[sp.point_type] = get!(counter, sp.point_type, 0) + 1
end
return counter
Expand Down
4 changes: 2 additions & 2 deletions src/codim1/resolve_point.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Parameters: @unpack
using ..Continuations: find_zero!
using ..BifurcationsBase: AbstractSpecialPoint, special_points,
using ..BifurcationsBase: AbstractSpecialPoint, special_intervals,
contkind, FixedPointCont, ContinuationKind

function default_resolve_exception_handler(err, interval, warn_exceptions)
Expand Down Expand Up @@ -34,7 +34,7 @@ function resolving_points(
rethrow()
end
nothing
end for interval in special_points(solver, args...))
end for interval in special_intervals(solver, args...))
end

resolved_points(solver::BifurcationSolver, args...; kwargs...) =
Expand Down
8 changes: 4 additions & 4 deletions src/codim2lc/factories.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Setfield: get, set

using ..Continuations: init, solve!, residual_jacobian, ContinuationSolver,
ZeroNotFoundError, FindZeroInputError
using ..BifurcationsBase: AbstractSpecialPoint, SpecialPoint, special_points
using ..BifurcationsBase: AbstractSpecialPoint, SpecialPoint, special_intervals
using ..Codim1
using ..Codim1: resolving_points, resolve_point
using ..Codim2
Expand Down Expand Up @@ -118,12 +118,12 @@ function nearest_fold_lc(lc_prob; lc_solver_opts...)
solve!(lc_solver)

PT = Codim1LimitCycle.PointTypes.saddle_node
point_candidates = special_points(lc_solver, PT)
point_candidates = special_intervals(lc_solver, PT)
if isempty(point_candidates)
error("Cannot find fold bifurcation of the limit cycle.")
end
sw1_points = special_points(lc_solver.sol.sweeps[1], PT)
sw2_points = special_points(lc_solver.sol.sweeps[2], PT)
sw1_points = special_intervals(lc_solver.sol.sweeps[1], PT)
sw2_points = special_intervals(lc_solver.sol.sweeps[2], PT)
sweep_index = -1
if length(sw2_points) == 0
@assert length(sw1_points) > 0
Expand Down
4 changes: 2 additions & 2 deletions src/plotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using .ArrayUtils: nan_
using .Continuations: as, ContinuationSweep, ContinuationSolution,
ContinuationSolver, sweeps_as_vectors
using .BifurcationsBase: BifurcationSweep, BifurcationSolution,
BifurcationSolver, special_points, measure, problem_of,
BifurcationSolver, special_intervals, measure, problem_of,
get_param_axis1, get_param_axis2
using .Codim1: Codim1Sweep, Codim1Solution, Codim1Solver,
AbstractCodim1SpecialPoint, stabilities, curves_by_stability,
Expand Down Expand Up @@ -318,7 +318,7 @@ function maybe_get_points(sweep, include_points, resolve_points)
if resolve_points
return resolved_points(sweep)
else
return special_points(sweep)
return special_intervals(sweep)
end
end
return []
Expand Down
6 changes: 3 additions & 3 deletions test/preamble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using Setfield: @lens
using Bifurcations
using Bifurcations.Codim1
using Bifurcations.Codim2
using Bifurcations: BifurcationProblem, special_points
using Bifurcations: BifurcationProblem, special_intervals
using Bifurcations.Codim2: cast_container

macro test_nothrow(ex)
Expand All @@ -34,14 +34,14 @@ function smoke_test_solver_show(solver)

for sweep in solver.sol.sweeps
@test_nothrow nullshow(sweep)
for point in special_points(sweep)
for point in special_intervals(sweep)
@test_nothrow nullshow(point)
end
end
end

function smoke_test_solver_plot(solver)
for p in special_points(solver)
for p in special_intervals(solver)
@test_nothrow nullshow(plot(p))
end
for sweep in solver.sol.sweeps
Expand Down
2 changes: 1 addition & 1 deletion test/test_bautin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ plt = plot(hopf_solver)

flc_prob = FoldLimitCycleProblem(
# codim2_points[1], # SpecialPointInterval is required ATM
special_points(hopf_solver, Codim2.PointTypes.bautin)[1],
special_intervals(hopf_solver, Codim2.PointTypes.bautin)[1],
hopf_solver;
num_mesh = 20,
degree = 3,
Expand Down
10 changes: 5 additions & 5 deletions test/test_bazykin_85.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ KNOWN_POINTS = Dict(
end

sn_point, = sort!(
special_points(codim1_solver, Codim1.PointTypes.saddle_node),
special_intervals(codim1_solver, Codim1.PointTypes.saddle_node),
by=p->p.u0[1])
hopf_point, = special_points(codim1_solver, Codim1.PointTypes.hopf)
hopf_point, = special_intervals(codim1_solver, Codim1.PointTypes.hopf)

hopf_solver1 = nothing
sn_solver1 = nothing
Expand Down Expand Up @@ -97,7 +97,7 @@ KNOWN_POINTS = Dict(
@assert hopf_solver1 !== nothing
# Find the right-most Bogdanov-Takens bifurcation:
point = first(sort(
special_points(hopf_solver1,
special_intervals(hopf_solver1,
Codim2.PointTypes.bogdanov_takens);
by = p -> p.u0[end - 1], # α
rev = true))
Expand All @@ -113,7 +113,7 @@ KNOWN_POINTS = Dict(
@assert sn_solver1 !== nothing
# Find the right-most Bogdanov-Takens bifurcation:
point = first(sort(
special_points(sn_solver1,
special_intervals(sn_solver1,
Codim2.PointTypes.bogdanov_takens);
by = p -> p.u0[end - 1], # α
rev = true))
Expand All @@ -124,7 +124,7 @@ KNOWN_POINTS = Dict(
hopf_solver2 = init(hopf_prob)
@test_nothrow solve!(hopf_solver2)

bpoints = special_points(hopf_solver2, Codim2.PointTypes.bautin)
bpoints = special_intervals(hopf_solver2, Codim2.PointTypes.bautin)
@test length(bpoints) == 1
@test_nothrow resolved_points(hopf_solver2, Codim2.PointTypes.bautin)
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_calcium.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using Bifurcations.Examples.Calcium
codim1 = init(Calcium.prob)
solve!(codim1)

for point in special_points(codim1)
for point in special_intervals(codim1)
codim2_prob = BifurcationProblem(
point,
codim1,
Expand Down
4 changes: 2 additions & 2 deletions test/test_hopf_to_lc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module TestHopfToLC
include("preamble_plots.jl")

using Bifurcations
using Bifurcations: special_points, LimitCycleProblem, limitcycles
using Bifurcations: special_intervals, LimitCycleProblem, limitcycles
using Bifurcations.Examples.PredatorPrey

solver0 = init(PredatorPrey.prob)
solve!(solver0)

hopf_point, = special_points(solver0, Codim1.PointTypes.hopf)
hopf_point, = special_intervals(solver0, Codim1.PointTypes.hopf)

period_max = 36.0
prob_lc = LimitCycleProblem(
Expand Down
12 changes: 6 additions & 6 deletions test/test_morris_lecar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ solver1 = init(
)
@time solve!(solver1)

all_specials = special_points(solver1)
all_hopf = special_points(solver1, Codim1.PointTypes.hopf)
all_sn = special_points(solver1, Codim1.PointTypes.saddle_node)
all_specials = special_intervals(solver1)
all_hopf = special_intervals(solver1, Codim1.PointTypes.hopf)
all_sn = special_intervals(solver1, Codim1.PointTypes.saddle_node)
@test length(all_specials) == 3
@test length(all_sn) == 2
@test length(all_hopf) == 1
Expand All @@ -42,7 +42,7 @@ hopf_solver = init(
)
solve!(hopf_solver)

all_bautin = special_points(hopf_solver, Codim2.PointTypes.bautin)
all_bautin = special_intervals(hopf_solver, Codim2.PointTypes.bautin)
@assert length(all_bautin) == 1
bautin_point, = all_bautin
bautin_point
Expand All @@ -69,7 +69,7 @@ flc_solver = init(


sn_prob = BifurcationProblem(
special_points(solver1, Codim1.PointTypes.saddle_node)[1],
special_intervals(solver1, Codim1.PointTypes.saddle_node)[1],
solver1,
(@lens _.z),
(-1.0, 1.0),
Expand All @@ -89,7 +89,7 @@ sn_solver = init(


hopf_prob2 = BifurcationProblem(
special_points(sn_solver, Codim2.PointTypes.bogdanov_takens)[1],
special_intervals(sn_solver, Codim2.PointTypes.bogdanov_takens)[1],
sn_solver,
)
hopf_solver2 = init(hopf_prob2)
Expand Down
2 changes: 1 addition & 1 deletion test/test_predator_prey.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CODIM1_KNOWN_POINTS = Dict(

@testset "codim-2 ($(nameof(ASType))) from $(point.u0[[1, end]])" for
ASType in [NormalizingAS, BackReferencingAS],
point in special_points(codim1_solver)
point in special_intervals(codim1_solver)

codim2_prob = BifurcationProblem(
point,
Expand Down

0 comments on commit d398cff

Please sign in to comment.