Skip to content

Commit db4cd24

Browse files
authored
Put backend tests into folders (#292)
* Restructure test folder * Rename translation into misc * Typo * More verbose * Typo * Fix 1.6
1 parent f80aab9 commit db4cd24

File tree

20 files changed

+61
-64
lines changed

20 files changed

+61
-64
lines changed

DifferentiationInterface/src/DifferentiationInterface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ include("sparse/matrices.jl")
7171
include("sparse/jacobian.jl")
7272
include("sparse/hessian.jl")
7373

74-
include("translation/differentiate_with.jl")
74+
include("misc/differentiate_with.jl")
7575

7676
function __init__()
7777
@require_extensions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using DifferentiationInterface, DifferentiationInterfaceTest
2+
import DifferentiationInterfaceTest as DIT
3+
using ForwardDiff: ForwardDiff
4+
using Zygote: Zygote
5+
using Test
6+
7+
function zygote_breaking_scenarios()
8+
onearg_scens = filter(default_scenarios()) do scen
9+
DIT.nb_args(scen) == 1
10+
end
11+
bad_onearg_scens = map(onearg_scens) do scen
12+
function bad_f(x)
13+
a = Vector{eltype(x)}(undef, 1)
14+
a[1] = sum(x)
15+
return scen.f(x)
16+
end
17+
wrapped_bad_f = DifferentiateWith(bad_f, AutoForwardDiff())
18+
bad_scen = DIT.change_function(scen, wrapped_bad_f)
19+
return bad_scen
20+
end
21+
return bad_onearg_scens
22+
end
23+
24+
test_differentiation(
25+
AutoZygote(), zygote_breaking_scenarios(); second_order=false, logging=LOGGING
26+
)
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using DifferentiationInterface, DifferentiationInterfaceTest
2-
import DifferentiationInterface as DI
3-
import DifferentiationInterfaceTest as DIT
42
using ForwardDiff: ForwardDiff
53
using SparseConnectivityTracer
64
using SparseMatrixColorings
@@ -32,26 +30,3 @@ test_differentiation(dense_backends; first_order=false, logging=LOGGING);
3230
test_differentiation(
3331
sparse_backends, sparse_scenarios(); first_order=false, sparsity=true, logging=LOGGING
3432
);
35-
36-
## Translation
37-
38-
function zygote_breaking_scenarios()
39-
onearg_scens = filter(default_scenarios()) do scen
40-
DIT.nb_args(scen) == 1
41-
end
42-
bad_onearg_scens = map(onearg_scens) do scen
43-
function bad_f(x)
44-
a = Vector{eltype(x)}(undef, 1)
45-
a[1] = sum(x)
46-
return scen.f(x)
47-
end
48-
wrapped_bad_f = DifferentiateWith(bad_f, AutoForwardDiff())
49-
bad_scen = DIT.change_function(scen, wrapped_bad_f)
50-
return bad_scen
51-
end
52-
return bad_onearg_scens
53-
end
54-
55-
test_differentiation(
56-
AutoZygote(), zygote_breaking_scenarios(); second_order=false, logging=LOGGING
57-
)

0 commit comments

Comments
 (0)