Skip to content

Commit d70c406

Browse files
Merge pull request #1142 from SciML/unitfulvalue
Properly extend unitfulvalue
2 parents 0b14061 + 48a894e commit d70c406

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DiffEqBase"
22
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "6.169.0"
4+
version = "6.169.1"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

ext/DiffEqBaseForwardDiffExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using DiffEqBase: Void, FunctionWrappersWrappers, OrdinaryDiffEqTag,
77
RecursiveArrayTools, reduce_tup, _promote_tspan, has_continuous_callback
88
import DiffEqBase: hasdualpromote, wrapfun_oop, wrapfun_iip, prob2dtmin,
99
promote_tspan, anyeltypedual, isdualtype, value, ODE_DEFAULT_NORM,
10-
InternalITP, nextfloat_tdir, DualEltypeChecker, sse
10+
InternalITP, nextfloat_tdir, DualEltypeChecker, sse, unitfulvalue
1111

1212
eltypedual(x) = eltype(x) <: ForwardDiff.Dual
1313
isdualtype(::Type{<:ForwardDiff.Dual}) = true
@@ -499,7 +499,7 @@ value(x::Type{ForwardDiff.Dual{T, V, N}}) where {T, V, N} = V
499499
value(x::ForwardDiff.Dual) = value(ForwardDiff.value(x))
500500

501501
unitfulvalue(x::Type{ForwardDiff.Dual{T, V, N}}) where {T, V, N} = V
502-
unitfulvalue(x::ForwardDiff.Dual) = unitfulvalue(ForwardDiff.unitfulvalue(x))
502+
unitfulvalue(x::ForwardDiff.Dual) = unitfulvalue(ForwardDiff.value(x))
503503

504504
sse(x::ForwardDiff.Dual) = sse(ForwardDiff.value(x)) + sum(sse, ForwardDiff.partials(x))
505505
function DiffEqBase.totallength(x::ForwardDiff.Dual)

test/downstream/unitful.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
using Unitful, OrdinaryDiffEq, Test
1+
using Unitful, OrdinaryDiffEq, ForwardDiff, Test
22
f(du, u, p, t) = du .= 3 * u"1/s" * u
33
prob = ODEProblem(f, [2.0u"m"], (0.0u"s", Inf * u"s"))
44
intg = init(prob, Tsit5())
55
@test_nowarn step!(intg, 0.02u"s", true)
6+
7+
@test DiffEqBase.unitfulvalue(u"1/s") == u"1/s"
8+
@test DiffEqBase.value(ForwardDiff.Dual(1)*u"1/s") == 1
9+
@test DiffEqBase.unitfulvalue(ForwardDiff.Dual(1)*u"1/s") == u"1/s"

0 commit comments

Comments
 (0)