Skip to content

Commit a4df324

Browse files
Handle empty Kwargs case in forwarddiff detection
Fixes #1074
1 parent c99ae4b commit a4df324

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/forwarddiff.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,14 @@ function anyeltypedual(x::NamedTuple, ::Type{Val{counter}} = Val{0}) where {coun
363363
anyeltypedual(values(x))
364364
end
365365

366-
function DiffEqBase.anyeltypedual(
366+
function anyeltypedual(
367367
f::SciMLBase.AbstractSciMLFunction, ::Type{Val{counter}}) where {counter}
368368
Any
369369
end
370370

371+
anyeltypedual(::@Kwargs{}, ::Type{Val{counter}} = Val{0}) where {counter} = Any
372+
anyeltypedual(::Type{@Kwargs{}}, ::Type{Val{counter}} = Val{0}) where {counter} = Any
373+
371374
@inline promote_u0(::Nothing, p, t0) = nothing
372375

373376
@inline function promote_u0(u0, p, t0)

test/forwarddiff_dual_detection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ p_possibilities = [ForwardDiff.Dual(2.0), (ForwardDiff.Dual(2.0), 2.0),
3636
(; x = 2.0, y = [ForwardDiff.Dual(2.0)]), (; x = 2.0, y = [[ForwardDiff.Dual(2.0)]]),
3737
Set([2.0, ForwardDiff.Dual(2.0)]), (SciMLBase.NullParameters(), ForwardDiff.Dual(2.0)),
3838
((), ForwardDiff.Dual(2.0)), ForwardDiff.Dual{Nothing}(ForwardDiff.Dual{MyStruct}(2.0)),
39-
(plot(), ForwardDiff.Dual(2.0)), [(1.0, ForwardDiff.Dual(1.0, (1.0,)))]
39+
(plot(), ForwardDiff.Dual(2.0)), [(1.0, ForwardDiff.Dual(1.0, (1.0,))), pairs((;))]
4040
]
4141

4242
for p in p_possibilities

0 commit comments

Comments
 (0)