-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathscenario.jl
More file actions
34 lines (28 loc) · 1.02 KB
/
scenario.jl
File metadata and controls
34 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using DifferentiationInterface
using DifferentiationInterfaceTest
using DifferentiationInterfaceTest: default_scenarios
using ForwardDiff: ForwardDiff
using Test
@testset "Naming" begin
scen = Scenario{:gradient,:out}(
sum, zeros(10); res1=ones(10), name="My pretty little scenario"
)
@test string(scen) == "My pretty little scenario"
testset = test_differentiation(
AutoForwardDiff(), [scen]; testset_name="My amazing test set"
)
data = benchmark_differentiation(
AutoForwardDiff(), [scen]; testset_name="My amazing test set"
)
end;
@testset "Compute results" begin
scens = default_scenarios()
new_scens = map(s -> compute_results(s, AutoForwardDiff()), scens)
isapprox_robust(x, y) = isapprox(x, y)
isapprox_robust(x::Nothing, y::Nothing) = true
isapprox_robust(x::NTuple, y::NTuple) = all(map(isapprox, x, y))
for (sa, sb) in zip(scens, new_scens)
@test isapprox_robust(sa.res1, sb.res1)
@test isapprox_robust(sa.res2, sb.res2)
end
end;