Skip to content

Commit 251f919

Browse files
author
Miha Zgubic
committed
implement to_vec for data types
1 parent 5b7d8f1 commit 251f919

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/to_vec.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ function to_vec(d::Dict)
235235
return d_vec, Dict_from_vec
236236
end
237237

238+
# types
239+
function FiniteDifferences.to_vec(x::DataType)
240+
function DataType_from_vec(x_vec::Vector)
241+
return x
242+
end
243+
return Bool[], DataType_from_vec
244+
end
238245

239246
# ChainRulesCore Differentials
240247
function FiniteDifferences.to_vec(x::Tangent{P}) where{P}

test/to_vec.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ end
195195
end
196196
end
197197

198+
@testset "DataType" begin
199+
test_to_vec(Float64) # isa DataType
200+
test_to_vec(Vector) # isa UnionAll
201+
end
202+
198203
@testset "ChainRulesCore Differentials" begin
199204
@testset "Tangent{Tuple}" begin
200205
@testset "basic" begin

0 commit comments

Comments
 (0)