Closed devmotion closed 5 months ago
Change it from T(0)
to value(T)(0)
?
I think actually that won't work 😄 https://github.com/SciML/DiffEqBase.jl/blob/ec7561abbe0185d0ed7903f5e0b850478fa875fe/src/forwarddiff.jl#L306-L307
The suggestions in the issue should work though, I'm about to prepare a PR.
Describe the bug 🐞
https://github.com/SciML/DiffEqBase.jl/pull/981 broke
ODE_DEFAULT_NORM
for arrays with nestedForwardDiff.Dual
s which since then returns aForwardDiff.Dual
(one layer ofDual
s removed). This is problematic e.g. in OrdinaryDiffEq whereintegrator.EEst
isintegrator.eigen_est
is initialized as a non-Dual
number and updated with output of the time-dependent norm which defaults toODE_DEFAULT_NORM
.More concretely, the main problem in #981 is that the
sum
s are initialized withT(0)
whereT
is the type of thevalue
of theDual
number which for nestedDual
numbers is again aDual
. Probably a better initialization would be something likeDiffEqBase.value(T(0))
orDiffEqBase.value(zero(T))
- or, consistent with thesum(sse, ...)
sse(T(0))
/sse(zero(T))
.Expected behavior
It should return a non-
Dual
number.Minimal Reproducible Example 👇
On DiffEqBase 6.144.2 and master (and probably all versions in-between) the call returns
whereas in 6.144.1 (prior to the linked PR) it returned
Environment (please complete the following information):