-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathtest.jl
More file actions
43 lines (37 loc) · 1.26 KB
/
test.jl
File metadata and controls
43 lines (37 loc) · 1.26 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
35
36
37
38
39
40
41
42
43
using Pkg
Pkg.activate(@__DIR__)
include("../../testutils.jl")
using DifferentiationInterface, DifferentiationInterfaceTest
using SparseMatrixColorings
using LinearAlgebra
using FastDifferentiation: FastDifferentiation
using Test
using ExplicitImports
check_no_implicit_imports(DifferentiationInterface)
for backend in [AutoFastDifferentiation(), AutoSparse(AutoFastDifferentiation())]
@test check_available(backend)
@test check_inplace(backend)
end
test_differentiation(
AutoFastDifferentiation(),
default_scenarios(;
include_constantified = true, include_cachified = true, use_tuples = false
);
logging = LOGGING,
);
test_differentiation(
AutoSparse(AutoFastDifferentiation()),
sparse_scenarios(; band_sizes = 0:-1);
sparsity = true,
logging = LOGGING,
);
@testset "SparseMatrixColorings access" begin
x = rand(10)
backend = AutoSparse(AutoFastDifferentiation())
jac_prep = prepare_jacobian(copy, backend, x)
jac!_prep = prepare_jacobian(copyto!, similar(x), backend, x)
hess_prep = prepare_hessian(x -> sum(abs2, x), backend, x)
@test sparsity_pattern(jac_prep) == Diagonal(trues(10))
@test sparsity_pattern(jac!_prep) == Diagonal(trues(10))
@test sparsity_pattern(hess_prep) == Diagonal(trues(10))
end