Skip to content

Commit 5d928d8

Browse files
author
Miha Zgubic
committed
add to_vec for thunks
1 parent 91d6652 commit 5d928d8

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/to_vec.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,9 @@ function FiniteDifferences.to_vec(x::AbstractZero)
193193
end
194194
return Bool[], AbstractZero_from_vec
195195
end
196+
197+
function FiniteDifferences.to_vec(t::Thunk)
198+
v, back = to_vec(unthunk(t))
199+
Thunk_from_vec = v -> @thunk(back(v))
200+
return v, Thunk_from_vec
201+
end

test/to_vec.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ end
176176
test_to_vec(ZeroTangent())
177177
test_to_vec(NoTangent())
178178
end
179+
180+
@testset "Thunks" begin
181+
test_to_vec(@thunk(3.2+4.3))
182+
end
179183
end
180184

181185
@testset "FillVector" begin

0 commit comments

Comments
 (0)