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 1
1
name = " FiniteDifferences"
2
2
uuid = " 26cc04aa-876d-5657-8c51-4c34ba976000"
3
- version = " 0.12.19 "
3
+ version = " 0.12.20 "
4
4
5
5
[deps ]
6
6
ChainRulesCore = " d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Original file line number Diff line number Diff line change @@ -235,12 +235,15 @@ function to_vec(d::Dict)
235
235
return d_vec, Dict_from_vec
236
236
end
237
237
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
242
246
end
243
- return Bool[], DataType_from_vec
244
247
end
245
248
246
249
# ChainRulesCore Differentials
@@ -255,13 +258,6 @@ function FiniteDifferences.to_vec(x::Tangent{P}) where{P}
255
258
return x_vec, Tangent_from_vec
256
259
end
257
260
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
-
265
261
function FiniteDifferences. to_vec (t:: Thunk )
266
262
v, back = to_vec (unthunk (t))
267
263
Thunk_from_vec = v -> @thunk (back (v))
Original file line number Diff line number Diff line change 200
200
test_to_vec (Vector; check_inferred= false ) # isa UnionAll
201
201
end
202
202
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
+
203
210
@testset " ChainRulesCore Differentials" begin
204
211
@testset " Tangent{Tuple}" begin
205
212
@testset " basic" begin
You can’t perform that action at this time.
0 commit comments