Skip to content

Commit c671fa9

Browse files
github-actions[bot]CompatHelper JuliaDatseris
authored
CompatHelper: bump compat for IntervalRootFinding to 0.6, (keep existing compat) (#338)
* CompatHelper: bump compat for IntervalRootFinding to 0.6, (keep existing compat) * address brealing changes * force the new version * update more interval arithmetic breakages * also update DSP compat * organize code better, still breaking * fixed fixed points!!! --------- Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org> Co-authored-by: Datseris <datseris.george@gmail.com>
1 parent ef7f1bf commit c671fa9

File tree

5 files changed

+49
-39
lines changed

5 files changed

+49
-39
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# main
22

3+
# v3.3
4+
5+
- Updated IntervalRootFinding.jl to v0.6 which [has breaking changes](https://github.com/JuliaIntervals/IntervalRootFinding.jl/releases/tag/v0.6.0) regarding
6+
the `fixedpoints` function (no more `IntervalBox` type).
7+
38
# v3.2
49
- `periodicorbits` uses new internal datastructure to avoid duplicates in the output. New keyword argument `abstol` is introduced and keyword argument `roundtol` is deprecated.
510
- `fixedpoints` can now use `order` keyword argument to compute fixed points of n-th order iterations of `DeterministicIteratedMap`.

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ChaosTools"
22
uuid = "608a59af-f2a3-5ad4-90b4-758bdf3122a7"
33
repo = "https://github.com/JuliaDynamics/ChaosTools.jl.git"
4-
version = "3.2.1"
4+
version = "3.3.0"
55

66
[deps]
77
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
@@ -25,12 +25,12 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
2525

2626
[compat]
2727
Combinatorics = "0.7, 1"
28-
DSP = "0.6, 0.7"
28+
DSP = "0.6, 0.7, 0.8"
2929
DataStructures = "0.18"
3030
Distances = "0.7, 0.8, 0.9, 0.10"
3131
Distributions = "0.21, 0.22, 0.23, 0.24, 0.25"
3232
DynamicalSystemsBase = "3"
33-
IntervalRootFinding = "0.5.9"
33+
IntervalRootFinding = "0.6"
3434
LombScargle = "1"
3535
Neighborhood = "0.2.2"
3636
Optim = "1.7"

src/stability/fixedpoints.jl

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import IntervalRootFinding, LinearAlgebra
2-
using IntervalRootFinding: (..), (×), IntervalBox, interval
3-
export fixedpoints, .., ×, IntervalBox, interval
2+
using IntervalRootFinding: (..), (×), interval
3+
export fixedpoints, .., ×, interval
44

55
"""
66
fixedpoints(ds::CoreDynamicalSystem, box, J = nothing; kwargs...) → fp, eigs, stable
@@ -12,11 +12,11 @@ Fixed points are returned as a [`StateSpaceSet`](@ref).
1212
For convenience, a vector of the Jacobian eigenvalues of each fixed point, and whether
1313
the fixed points are stable or not, are also returned.
1414
15-
`box` is an appropriate `IntervalBox` from IntervalRootFinding.jl.
15+
`box` is an appropriate interval box from IntervalRootFinding.jl (a vector of intervals).
1616
E.g. for a 3D system it would be something like
1717
```julia
18-
v, z = -5..5, -2..2 # 1D intervals, can use `interval(-5, 5)` instead
19-
box = v × v × z # `\\times = ×`, or use `IntervalBox(v, v, z)` instead
18+
v, z = interval(-5, 5), interval(-2, 2) # 1D intervals
19+
box = [v, v, z]
2020
```
2121
2222
`J` is the Jacobian of the dynamic rule of `ds`.
@@ -37,14 +37,14 @@ as a start of a continuation process. See also [`periodicorbits`](@ref).
3737
see the docs of IntervalRootFinding.jl for all possibilities.
3838
- `tol = 1e-15` is the root-finding tolerance.
3939
- `warn = true` throw a warning if no fixed points are found.
40-
- `order = nothing` search for fixed points of the n-th iterate of
40+
- `order = nothing` search for fixed points of the n-th iterate of
4141
[`DeterministicIteratedMap`](@ref). Must be a positive integer or `nothing`.
4242
Select `nothing` or 1 to search for the fixed points of the original map.
4343
4444
## Performance notes
4545
46-
Setting `order` to a value greater than 5 can be very slow. Consider using
47-
more suitable algorithms for periodic orbit detection, such as
46+
Setting `order` to a value greater than 5 can be very slow. Consider using
47+
more suitable algorithms for periodic orbit detection, such as
4848
[`periodicorbits`](@ref).
4949
5050
"""
@@ -55,27 +55,30 @@ function fixedpoints(ds::DynamicalSystem, box, J = nothing;
5555
if isinplace(ds)
5656
error("`fixedpoints` currently works only for out-of-place dynamical systems.")
5757
end
58+
if box isa Vector
59+
# since the code only works for out of place we can always convert
60+
box = SVector{length(box)}(box)
61+
end
5862

5963
if !(isnothing(order) || (isa(order, Int) && order > 0))
6064
error("`order` must be a positive integer or `nothing`.")
6165
end
6266

63-
# Jacobian: copy code from `DynamicalSystemsBase`
64-
f = dynamic_rule(ds)
6567
p = current_parameters(ds)
66-
if isnothing(J)
67-
Jf(u, p, t) = DynamicalSystemsBase.ForwardDiff.jacobian(x -> f(x, p, 0.0), u)
68-
else
69-
Jf = J
70-
end
7168
# Find roots via IntervalRootFinding.jl
7269
fun = to_root_f(ds, p, order)
73-
jac = to_root_J(Jf, ds, p, order)
74-
r = IntervalRootFinding.roots(fun, jac, box, method, tol)
70+
jac = to_root_J(J, ds, p, order)
71+
r = IntervalRootFinding.roots(fun, box; abstol = tol, derivative = jac, contractor = method)
7572
D = dimension(ds)
7673
fp = roots_to_dataset(r, D, warn)
77-
# Find eigenvalues and stability
74+
# extract eigenvalues and stability
7875
eigs = Vector{Vector{Complex{Float64}}}(undef, length(fp))
76+
if isnothing(J)
77+
f = dynamic_rule(ds)
78+
Jf(u, p, t = 0) = DynamicalSystemsBase.ForwardDiff.jacobian(x -> f(x, p, t), u)
79+
else
80+
Jf = J
81+
end
7982
Jm = zeros(dimension(ds), dimension(ds)) # `eigvals` doesn't work with `SMatrix`
8083
for (i, u) in enumerate(fp)
8184
Jm .= Jf(u, p, 0) # notice that we use the "pure" jacobian, no -u!
@@ -85,11 +88,13 @@ function fixedpoints(ds::DynamicalSystem, box, J = nothing;
8588
return fp, eigs, stable
8689
end
8790

91+
to_root_J(Jf::Nothing, ::DynamicalSystem, args...) = nothing
92+
8893
to_root_f(ds::CoupledODEs, p, ::Nothing) = u -> dynamic_rule(ds)(u, p, 0.0)
89-
to_root_J(Jf, ::CoupledODEs, p, ::Nothing) = u -> Jf(u, p, 0.0)
94+
to_root_J(Jf::Function, ::CoupledODEs, p, ::Nothing) = u -> Jf(u, p, 0)
9095

9196
to_root_f(ds::DeterministicIteratedMap, p, ::Nothing) = u -> dynamic_rule(ds)(u, p, 0) - u
92-
function to_root_J(Jf, ds::DeterministicIteratedMap, p, ::Nothing)
97+
function to_root_J(Jf::Function, ds::DeterministicIteratedMap, p, ::Nothing)
9398
c = Diagonal(ones(typeof(current_state(ds))))
9499
return u -> Jf(u, p, 0) - c
95100
end
@@ -132,7 +137,7 @@ function roots_to_dataset(r, D, warn)
132137
end
133138
F = zeros(length(r), D)
134139
for (j, root) in enumerate(r)
135-
F[j, :] .= map(i -> (i.hi + i.lo)/2, root.interval)
140+
F[j, :] .= map(i -> (i.bareinterval.hi + i.bareinterval.lo)/2, root.region)
136141
end
137142
return StateSpaceSet(F; warn = false)
138143
end

test/runtests.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ defaultname(file) = uppercasefirst(replace(splitext(basename(file))[1], '_' => '
1818

1919
@testset "ChaosTools" begin
2020

21-
include("timeevolution/orbitdiagram.jl")
21+
testfile("timeevolution/orbitdiagram.jl")
2222

2323
testfile("chaosdetection/lyapunovs.jl")
2424
testfile("chaosdetection/gali.jl")
25-
include("chaosdetection/partially_predictable.jl")
26-
include("chaosdetection/01test.jl")
25+
testfile("chaosdetection/partially_predictable.jl")
26+
testfile("chaosdetection/01test.jl")
2727
testfile("chaosdetection/expansionentropy.jl")
2828

29-
include("stability/fixedpoints.jl")
30-
include("periodicity/periodicorbits.jl")
31-
include("periodicity/davidchacklai.jl")
32-
include("periodicity/period.jl")
29+
testfile("stability/fixedpoints.jl")
30+
testfile("periodicity/periodicorbits.jl")
31+
testfile("periodicity/davidchacklai.jl")
32+
testfile("periodicity/period.jl")
3333

3434
# testfile("rareevents/return_time_tests.jl", "Return times")
3535

test/stability/fixedpoints.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using ChaosTools, Test
22

33
@testset "Henon map" begin
4-
henon_rule(x, p, n) = SVector{2}(1.0 - p[1]*x[1]^2 + x[2], p[2]*x[1])
5-
henon_jacob(x, p, n) = SMatrix{2,2}(-2*p[1]*x[1], p[2], 1.0, 0.0)
4+
henon_rule(x, p, n = 0) = SVector{2}(1.0 - p[1]*x[1]^2 + x[2], p[2]*x[1])
5+
henon_jacob(x, p, n = 0) = SMatrix{2,2}(-2*p[1]*x[1], p[2], 1.0, 0.0)
66
ds = DeterministicIteratedMap(henon_rule, zeros(2), [1.4, 0.3])
77
x = interval(-1.5, 1.5)
88
y = interval(-0.5, 0.5)
9-
box = x × y
9+
box = [x, y]
1010

1111
# henon fixed points analytically
1212
hmfp(a, b) = (x = -(1-b)/2a - sqrt((1-b)^2 + 4a)/2a; return SVector(x, b*x))
@@ -45,7 +45,7 @@ end
4545
ds = DeterministicIteratedMap(henon_rule, zeros(2), [1.4, 0.3])
4646
x = interval(-3.0, 3.0)
4747
y = interval(-10.0, 10.0)
48-
box = x × y
48+
box = [x, y]
4949
o = 4
5050
fp, eigs, stable = fixedpoints(ds, box, henon_jacob; order=o)
5151
tol = 1e-8
@@ -74,10 +74,10 @@ end
7474
end
7575
end
7676

77-
x = -20..20
78-
y = -20..20
79-
z = 0.0..40
80-
box = x × y × z
77+
x = interval(-20, 20)
78+
y = interval(-20, 20)
79+
z = interval(0, 40)
80+
box = [x, y, z]
8181
σ = 10.0
8282
β = 8/3
8383
lorenzfp(ρ, β) = [

0 commit comments

Comments
 (0)