Skip to content

Commit

Permalink
Return Partials from partials
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Dec 12, 2024
1 parent 3be1cf2 commit d05bb57
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ end
@inline partials(x) = Partials{0,typeof(x)}(tuple())
@inline partials(d::Dual) = d.partials
@inline partials(d::Complex{<:Dual}, i) = complex(partials(real(d), i), partials(imag(d), i))
@inline partials(d::Complex{<:Dual}) = complex.(partials(real(d)), partials(imag(d)))
@inline partials(d::Complex{<:Dual}) = Partials(complex.(partials(real(d)).values, partials(imag(d)).values))
@inline partials(x, i...) = zero(x)
@inline Base.@propagate_inbounds partials(d::Dual, i) = d.partials[i]
@inline Base.@propagate_inbounds partials(d::Dual, i, j) = partials(d, i).partials[j]
Expand Down
1 change: 1 addition & 0 deletions test/DualTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ end
@test partials(x,1) == 2 + 5im
@test partials(x,2) == 3 + 6im
@test partials(x) == [2+5im,3+6im]
@test partials(x) isa Partials
@test npartials(x) == npartials(typeof(x)) == 2
end

Expand Down

0 comments on commit d05bb57

Please sign in to comment.