File tree Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Expand file tree Collapse file tree 3 files changed +16
-13
lines changed Original file line number Diff line number Diff line change 11name = " FiniteDifferences"
22uuid = " 26cc04aa-876d-5657-8c51-4c34ba976000"
3- version = " 0.12.19 "
3+ version = " 0.12.20 "
44
55[deps ]
66ChainRulesCore = " d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Original file line number Diff line number Diff line change @@ -235,12 +235,15 @@ function to_vec(d::Dict)
235235 return d_vec, Dict_from_vec
236236end
237237
238- # types
239- function FiniteDifferences. to_vec (x:: DataType )
240- function DataType_from_vec (x_vec:: Vector )
241- return x
238+ # non-perturbable types
239+ for T in (:DataType , :CartesianIndex , :AbstractZero )
240+ T_from_vec = Symbol (T, :_from_vec )
241+ @eval function FiniteDifferences. to_vec (x:: $T )
242+ function $T_from_vec (x_vec:: Vector )
243+ return x
244+ end
245+ return Bool[], $ T_from_vec
242246 end
243- return Bool[], DataType_from_vec
244247end
245248
246249# ChainRulesCore Differentials
@@ -255,13 +258,6 @@ function FiniteDifferences.to_vec(x::Tangent{P}) where{P}
255258 return x_vec, Tangent_from_vec
256259end
257260
258- function FiniteDifferences. to_vec (x:: AbstractZero )
259- function AbstractZero_from_vec (x_vec:: Vector )
260- return x
261- end
262- return Bool[], AbstractZero_from_vec
263- end
264-
265261function FiniteDifferences. to_vec (t:: Thunk )
266262 v, back = to_vec (unthunk (t))
267263 Thunk_from_vec = v -> @thunk (back (v))
Original file line number Diff line number Diff line change 200200 test_to_vec (Vector; check_inferred= false ) # isa UnionAll
201201 end
202202
203+ @testset " CartesianIndex" begin
204+ test_to_vec (CartesianIndex (1 ))
205+ test_to_vec (CartesianIndex (1 , 2 ))
206+ @test to_vec (CartesianIndex (1 ))[1 ] == []
207+ @test to_vec (CartesianIndex (1 , 3 ))[1 ] == []
208+ end
209+
203210 @testset " ChainRulesCore Differentials" begin
204211 @testset " Tangent{Tuple}" begin
205212 @testset " basic" begin
You can’t perform that action at this time.
0 commit comments