From 6db10d92d874f5b795de95f37be035ea280e86f7 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 14 Apr 2025 00:07:39 +0200 Subject: [PATCH 1/3] Update and simplify NaN-safe mode instructions --- docs/src/user/advanced.md | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/docs/src/user/advanced.md b/docs/src/user/advanced.md index 9e2ca8ee..07b5e95e 100644 --- a/docs/src/user/advanced.md +++ b/docs/src/user/advanced.md @@ -149,20 +149,9 @@ ForwardDiff's `NaN`-safe mode by using the the `nansafe_mode` preference to true, for example via: ```julia -julia> using ForwardDiff, Preferences +julia> using Preferences julia> set_preferences!(ForwardDiff, "nansafe_mode" => true) -``` - -Note that Julia has to be restarted and ForwardDiff has to be reloaded after changing -this preference. - -Alternatively, you can set the preference before loading ForwardDiff, for example via: - -```julia -julia> using Preferences, UUIDs - -julia> set_preferences!(UUID("f6369f11-7733-5829-9624-2563aa707210"), "nansafe_mode" => true) julia> using ForwardDiff @@ -170,6 +159,10 @@ julia> log(ForwardDiff.Dual{:tag}(0.0, 0.0)) Dual{:tag}(-Inf,0.0) ``` +!!! warn + The preference has to be set **before** loading ForwardDiff. + If you change it after loading ForwardDiff, you have to restart your Julia session and reload ForwardDiff for it to become active. + In the future, we plan on allowing users and downstream library authors to dynamically enable [`NaN`-safe mode via the `AbstractConfig` API](https://github.com/JuliaDiff/ForwardDiff.jl/issues/181). From fe02814da30b046f934f07e392c8f82782dd74a7 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Mon, 14 Apr 2025 00:11:31 +0200 Subject: [PATCH 2/3] Fix typo --- docs/src/user/advanced.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/user/advanced.md b/docs/src/user/advanced.md index 07b5e95e..fb99820b 100644 --- a/docs/src/user/advanced.md +++ b/docs/src/user/advanced.md @@ -151,7 +151,7 @@ the `nansafe_mode` preference to true, for example via: ```julia julia> using Preferences -julia> set_preferences!(ForwardDiff, "nansafe_mode" => true) +julia> set_preferences!("ForwardDiff", "nansafe_mode" => true) julia> using ForwardDiff From 6127a6c5e83bf5cab567b95bb62f089d887cadc2 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Wed, 23 Apr 2025 09:20:21 +0200 Subject: [PATCH 3/3] Update docs/src/user/advanced.md Co-authored-by: Michael Abbott <32575566+mcabbott@users.noreply.github.com> --- docs/src/user/advanced.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/user/advanced.md b/docs/src/user/advanced.md index fb99820b..2a68b95a 100644 --- a/docs/src/user/advanced.md +++ b/docs/src/user/advanced.md @@ -161,7 +161,8 @@ Dual{:tag}(-Inf,0.0) !!! warn The preference has to be set **before** loading ForwardDiff. - If you change it after loading ForwardDiff, you have to restart your Julia session and reload ForwardDiff for it to become active. + If you change it after loading ForwardDiff, you have to restart your Julia session (using the same environment) + and then reload ForwardDiff for it to become active. In the future, we plan on allowing users and downstream library authors to dynamically enable [`NaN`-safe mode via the `AbstractConfig`