Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle tuples with types in them #236

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/stage1/recurse_fwd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ function (::∂☆new{1})(B::Type, xs::AbstractTangentBundle{1}...)
tangent_nt = NamedTuple{names}(tangent_tup)
Tangent{B, typeof(tangent_nt)}(tangent_nt)
end
return TaylorBundle{1, B}(the_primal, (the_partial,))
B2 = typeof(the_primal) # HACK: if the_primal actually has types in it then we want to make sure we get DataType not Type(...)
return TaylorBundle{1, B2}(the_primal, (the_partial,))
end

function (::∂☆new{N})(B::Type, xs::AbstractTangentBundle{N}...) where {N}
Expand Down
12 changes: 12 additions & 0 deletions test/forward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ end
end


@testset "types in tuples" begin
function foo(a)
tup = (a, 2a, Int)
return tup[2]
end

let var"'" = Diffractor.PrimeDerivativeFwd
@test foo'(100.0) == 2.0
end
end


@testset "taylor_compatible" begin
taylor_compatible = Diffractor.taylor_compatible

Expand Down
Loading