Skip to content

Commit

Permalink
fix: remove deprecated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 21, 2024
1 parent c73bcf4 commit 280b8d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 48 deletions.
19 changes: 0 additions & 19 deletions docs/src/basics/sparsity_detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,3 @@ prob = NonlinearProblem(

Refer to the documentation of DifferentiationInterface.jl and SparseConnectivityTracer.jl
for more information on sparsity detection algorithms.

## Case III: Sparse AD Type is being Used

!!! warning

This is now deprecated. Please use the previous two cases instead.

If you constructed a Nonlinear Solver with a sparse AD type, for example

```julia
NewtonRaphson(; autodiff = AutoSparse(AutoForwardDiff()))
# OR
TrustRegion(; autodiff = AutoSparse(AutoZygote()))
```

then NonlinearSolve will automatically perform matrix coloring and use sparse
differentiation if none of `sparsity` or `jac_prototype` is provided. We default to using
`TracerSparsityDetector()`. `Case I/II` take precedence for sparsity detection and we
perform sparse AD based on those options if those are provided.
15 changes: 0 additions & 15 deletions docs/src/basics/termination_condition.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,3 @@ not used as a default anywhere.
```@docs
SimpleNonlinearSolveTerminationMode
```

### Return Codes (Deprecated)

These are deprecated and will be removed in a future release. Use the
`use_deprecated_retcodes = Val(false)` option to `SciMLBase.init` to use the new return
`ReturnCode` versions.

```@docs
DiffEqBase.NonlinearSafeTerminationReturnCode
DiffEqBase.NonlinearSafeTerminationReturnCode.Success
DiffEqBase.NonlinearSafeTerminationReturnCode.Default
DiffEqBase.NonlinearSafeTerminationReturnCode.Failure
DiffEqBase.NonlinearSafeTerminationReturnCode.PatienceTermination
DiffEqBase.NonlinearSafeTerminationReturnCode.ProtectiveTermination
```
29 changes: 15 additions & 14 deletions test/core/rootfind_tests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@testsetup module CoreRootfindTesting
using Reexport
@reexport using BenchmarkTools, LinearSolve, NonlinearSolve, StaticArrays, Random,
LinearAlgebra, ForwardDiff, Zygote, Enzyme, DiffEqBase
LinearAlgebra, ForwardDiff, Zygote, Enzyme, DiffEqBase,
SparseConnectivityTracer
using LineSearches: LineSearches

_nameof(x) = applicable(nameof, x) ? nameof(x) : _nameof(typeof(x))
Expand Down Expand Up @@ -116,12 +117,12 @@ end
@test nlprob_iterator_interface(quadratic_f, p, Val(false), NewtonRaphson()) sqrt.(p)
@test nlprob_iterator_interface(quadratic_f!, p, Val(true), NewtonRaphson()) sqrt.(p)

@testset "ADType: $(autodiff) u0: $(_nameof(u0))" for autodiff in (
AutoSparse(AutoForwardDiff()), AutoSparse(AutoFiniteDiff()),
AutoZygote(), AutoSparse(AutoZygote()), AutoSparse(AutoEnzyme())),
@testset "Sparsity ADType: $(autodiff) u0: $(_nameof(u0))" for autodiff in (
AutoForwardDiff(), AutoFiniteDiff(), AutoZygote(), AutoEnzyme()),
u0 in (1.0, [1.0, 1.0])

probN = NonlinearProblem(quadratic_f, u0, 2.0)
probN = NonlinearProblem(
NonlinearFunction(quadratic_f; sparsity = TracerSparsityDetector()), u0, 2.0)
@test all(solve(probN, NewtonRaphson(; autodiff)).u .≈ sqrt(2.0))
end

Expand Down Expand Up @@ -180,12 +181,12 @@ end
@test nlprob_iterator_interface(quadratic_f!, p, Val(true), TrustRegion()) sqrt.(p)

@testset "$(_nameof(autodiff)) u0: $(_nameof(u0)) $(radius_update_scheme)" for autodiff in (
AutoSparse(AutoForwardDiff()), AutoSparse(AutoFiniteDiff()),
AutoZygote(), AutoSparse(AutoZygote()), AutoSparse(AutoEnzyme())),
AutoForwardDiff(), AutoFiniteDiff(), AutoZygote(), AutoEnzyme()),
u0 in (1.0, [1.0, 1.0]),
radius_update_scheme in radius_update_schemes

probN = NonlinearProblem(quadratic_f, u0, 2.0)
probN = NonlinearProblem(
NonlinearFunction(quadratic_f; sparsity = TracerSparsityDetector()), u0, 2.0)
@test all(solve(probN, TrustRegion(; autodiff, radius_update_scheme)).u .≈
sqrt(2.0))
end
Expand Down Expand Up @@ -276,11 +277,11 @@ end
end

@testset "ADType: $(autodiff) u0: $(_nameof(u0))" for autodiff in (
AutoSparse(AutoForwardDiff()), AutoSparse(AutoFiniteDiff()),
AutoZygote(), AutoSparse(AutoZygote()), AutoSparse(AutoEnzyme())),
AutoForwardDiff(), AutoFiniteDiff(), AutoZygote(), AutoEnzyme()),
u0 in (1.0, [1.0, 1.0])

probN = NonlinearProblem(quadratic_f, u0, 2.0)
probN = NonlinearProblem(
NonlinearFunction(quadratic_f; sparsity = TracerSparsityDetector()), u0, 2.0)
@test all(solve(
probN, LevenbergMarquardt(; autodiff); abstol = 1e-9, reltol = 1e-9).u .≈
sqrt(2.0))
Expand Down Expand Up @@ -458,11 +459,11 @@ end
quadratic_f!, p, Val(true), PseudoTransient(; alpha_initial = 10.0)) sqrt.(p)

@testset "ADType: $(autodiff) u0: $(_nameof(u0))" for autodiff in (
AutoSparse(AutoForwardDiff()), AutoSparse(AutoFiniteDiff()),
AutoZygote(), AutoSparse(AutoZygote()), AutoSparse(AutoEnzyme())),
AutoForwardDiff(), AutoFiniteDiff(), AutoZygote(), AutoEnzyme()),
u0 in (1.0, [1.0, 1.0])

probN = NonlinearProblem(quadratic_f, u0, 2.0)
probN = NonlinearProblem(
NonlinearFunction(quadratic_f; sparsity = TracerSparsityDetector()), u0, 2.0)
@test all(solve(probN, PseudoTransient(; alpha_initial = 10.0, autodiff)).u .≈
sqrt(2.0))
end
Expand Down

0 comments on commit 280b8d4

Please sign in to comment.