Skip to content

Commit f8f7d07

Browse files
ErikQQYgdalle
andauthored
Relax type annotations in sparse prep (#647)
* Relax type annotations in sparse prep * f should be specified as nothing in test case * Test complex numbers with FiniteDiff --------- Co-authored-by: Guillaume Dalle <22795598+gdalle@users.noreply.github.com>
1 parent fd3dc14 commit f8f7d07

5 files changed

Lines changed: 14 additions & 4 deletions

File tree

DifferentiationInterface/ext/DifferentiationInterfaceSparseMatrixColoringsExt/hessian.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
struct SparseHessianPrep{
22
BS<:BatchSizeSettings,
33
C<:AbstractColoringResult{:symmetric,:column},
4-
M<:AbstractMatrix{<:Real},
4+
M<:AbstractMatrix{<:Number},
55
S<:AbstractVector{<:NTuple},
66
R<:AbstractVector{<:NTuple},
77
E2<:HVPPrep,

DifferentiationInterface/ext/DifferentiationInterfaceSparseMatrixColoringsExt/jacobian.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
struct PushforwardSparseJacobianPrep{
44
BS<:BatchSizeSettings,
55
C<:AbstractColoringResult{:nonsymmetric,:column},
6-
M<:AbstractMatrix{<:Real},
6+
M<:AbstractMatrix{<:Number},
77
S<:AbstractVector{<:NTuple},
88
R<:AbstractVector{<:NTuple},
99
E<:PushforwardPrep,
@@ -19,7 +19,7 @@ end
1919
struct PullbackSparseJacobianPrep{
2020
BS<:BatchSizeSettings,
2121
C<:AbstractColoringResult{:nonsymmetric,:row},
22-
M<:AbstractMatrix{<:Real},
22+
M<:AbstractMatrix{<:Number},
2323
S<:AbstractVector{<:NTuple},
2424
R<:AbstractVector{<:NTuple},
2525
E<:PullbackPrep,

DifferentiationInterface/ext/DifferentiationInterfaceSparseMatrixColoringsExt/jacobian_mixed.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ struct MixedModeSparseJacobianPrep{
44
BSf<:BatchSizeSettings,
55
BSr<:BatchSizeSettings,
66
C<:AbstractColoringResult{:nonsymmetric,:bidirectional},
7-
M<:AbstractMatrix{<:Real},
7+
M<:AbstractMatrix{<:Number},
88
Sf<:Vector{<:NTuple},
99
Sr<:Vector{<:NTuple},
1010
Rf<:Vector{<:NTuple},

DifferentiationInterface/test/Back/FiniteDiff/test.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Pkg.add("FiniteDiff")
33

44
using DifferentiationInterface, DifferentiationInterfaceTest
55
using FiniteDiff: FiniteDiff
6+
using SparseMatrixColorings
67
using Test
78

89
LOGGING = get(ENV, "CI", "false") == "false"
@@ -18,3 +19,11 @@ test_differentiation(
1819
excluded=[:second_derivative, :hvp],
1920
logging=LOGGING,
2021
);
22+
23+
@testset verbose = true "Complex number support" begin
24+
backend = AutoSparse(AutoFiniteDiff(); coloring_algorithm=GreedyColoringAlgorithm())
25+
x = float.(1:3) .+ im
26+
@test_nowarn jacobian(identity, backend, x)
27+
@test_nowarn jacobian(copyto!, similar(x), backend, x)
28+
@test_nowarn hessian(sum, backend, x)
29+
end

DifferentiationInterface/test/Back/ForwardDiff/test.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Pkg
22
Pkg.add("ForwardDiff")
33

4+
using ADTypes: ADTypes
45
using ComponentArrays: ComponentArrays
56
using DifferentiationInterface, DifferentiationInterfaceTest
67
import DifferentiationInterfaceTest as DIT

0 commit comments

Comments
 (0)