From f2f8fbc447b9e3a12c3c0f341fb4946422f64b79 Mon Sep 17 00:00:00 2001 From: Olivier Cots Date: Thu, 20 Jun 2024 15:22:31 +0200 Subject: [PATCH] add change of default AD backend --- src/CTBase.jl | 3 ++- src/default.jl | 10 +++++++++- test/test_description.jl | 3 --- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/CTBase.jl b/src/CTBase.jl index 5e03391d..a7205edd 100644 --- a/src/CTBase.jl +++ b/src/CTBase.jl @@ -236,7 +236,8 @@ export Description, add, getFullDescription export CTException, ParsingError, AmbiguousDescription, IncorrectMethod export IncorrectArgument, IncorrectOutput, NotImplemented, UnauthorizedCall -# checking +# AD +export set_AD_backend # functions export Hamiltonian, HamiltonianVectorField, VectorField diff --git a/src/default.jl b/src/default.jl index 3d2f9acb..d9cd0a5e 100644 --- a/src/default.jl +++ b/src/default.jl @@ -1,3 +1,11 @@ +# +global __default_AD_backend = AutoForwardDiff() + +function set_AD_backend(AD) + global __default_AD_backend = AD + nothing +end + """ $(TYPEDSIGNATURES) @@ -5,7 +13,7 @@ Used to set the default value of Automatic Differentiation backend. The default value is `AutoForwardDiff()`, that is the `ForwardDiff` package is used by default. """ -__auto() = AutoForwardDiff() # default AD backend +__auto() = __default_AD_backend # default AD backend """ $(TYPEDSIGNATURES) diff --git a/test/test_description.jl b/test/test_description.jl index 5dd1bf23..87b2931c 100644 --- a/test/test_description.jl +++ b/test/test_description.jl @@ -7,9 +7,6 @@ descriptions = add(descriptions, (:b,)) @test descriptions[1] == (:a,) @test descriptions[2] == (:b,) -# print a tuple of descriptions -@test display(descriptions) isa Nothing - # get the complete description of the chosen method algorithmes = () algorithmes = add(algorithmes, (:descent, :bfgs, :bissection))