Skip to content

Commit 710ce0b

Browse files
committed
Add a non-deprecating code path
1 parent 60d5e48 commit 710ce0b

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BoundaryValueDiffEq"
22
uuid = "764a87c0-6b3e-53db-9096-fe964310641d"
3-
version = "6.0.0"
3+
version = "5.4.0"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

src/algorithms.jl

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Single shooting method, reduces BVP to an initial value problem and solves the I
1515
## Keyword Arguments
1616
1717
- `nlsolve`: Internal Nonlinear solver. Any solver which conforms to the SciML
18-
`NonlinearProblem` interface can be used.Note that any autodiff argument for the solver
18+
`NonlinearProblem` interface can be used. Note that any autodiff argument for the solver
1919
will be ignored and a custom jacobian algorithm will be used.
2020
- `jac_alg`: Jacobian Algorithm used for the nonlinear solver. Defaults to
2121
`BVPJacobianAlgorithm()`, which automatically decides the best algorithm to use based
@@ -39,12 +39,25 @@ function concretize_jacobian_algorithm(alg::Shooting, prob)
3939
return Shooting(alg.ode_alg, alg.nlsolve, BVPJacobianAlgorithm(diffmode))
4040
end
4141

42-
function Shooting(ode_alg, nlsolve; jac_alg = BVPJacobianAlgorithm())
42+
function Shooting(ode_alg; nlsolve = NewtonRaphson(), jac_alg = nothing)
43+
jac_alg === nothing && (jac_alg = __propagate_nlsolve_ad_to_jac_alg(nlsolve))
4344
return Shooting(ode_alg, nlsolve, jac_alg)
4445
end
4546

46-
function Shooting(ode_alg; nlsolve = NewtonRaphson(), jac_alg = BVPJacobianAlgorithm())
47-
return Shooting(ode_alg, nlsolve, jac_alg)
47+
Shooting(ode_alg, nlsolve; jac_alg = nothing) = Shooting(ode_alg; nlsolve, jac_alg)
48+
49+
# This is a deprecation path. We forward the `ad` from nonlinear solver to `jac_alg`.
50+
# We will drop this function in
51+
function __propagate_nlsolve_ad_to_jac_alg(nlsolve::N) where {N}
52+
# Defaults so no depwarn
53+
nlsolve === nothing && return BVPJacobianAlgorithm()
54+
ad = hasfield(N, :ad) ? nlsolve.ad : nothing
55+
ad === nothing && return BVPJacobianAlgorithm()
56+
57+
Base.depwarn("Setting autodiff to the nonlinear solver in Shooting has been deprecated \
58+
and will have no effect from the next major release. Update to use \
59+
`BVPJacobianAlgorithm` directly", :Shooting)
60+
return BVPJacobianAlgorithm(ad)
4861
end
4962

5063
"""

test/shooting/shooting_tests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,12 @@ end
161161
bc_flow!(resid, sol_msshooting, p, sol_msshooting.t)
162162
@test norm(resid, Inf) < 1e-6
163163
end
164+
165+
@testset "Testing Deprecations" begin
166+
@test_deprecated Shooting(Tsit5();
167+
nlsolve = NewtonRaphson(; autodiff = AutoForwardDiff(chunksize = 2)))
168+
169+
alg = Shooting(Tsit5();
170+
nlsolve = NewtonRaphson(; autodiff = AutoForwardDiff(chunksize = 2)))
171+
@test alg.jac_alg.diffmode == AutoForwardDiff(chunksize = 2)
172+
end

0 commit comments

Comments
 (0)