Skip to content

Commit a06f5de

Browse files
committed
Typing
1 parent efc8fcf commit a06f5de

10 files changed

Lines changed: 30 additions & 20 deletions

File tree

DifferentiationInterface/src/first_order/derivative.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
$(docstring_prepare("derivative"; inplace=true))
88
"""
99
function prepare_derivative(
10-
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict=Val(false)
10+
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict::Val=Val(false)
1111
) where {F,C}
1212
return prepare_derivative_nokwarg(strict, f, backend, x, contexts...)
1313
end
1414

1515
function prepare_derivative(
16-
f!::F, y, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict=Val(false)
16+
f!::F,
17+
y,
18+
backend::AbstractADType,
19+
x,
20+
contexts::Vararg{Context,C};
21+
strict::Val=Val(false),
1722
) where {F,C}
1823
return prepare_derivative_nokwarg(strict, f!, y, backend, x, contexts...)
1924
end

DifferentiationInterface/src/first_order/gradient.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$(docstring_prepare("gradient"))
77
"""
88
function prepare_gradient(
9-
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict=Val(false)
9+
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict::Val=Val(false)
1010
) where {F,C}
1111
return prepare_gradient_nokwarg(strict, f, backend, x, contexts...)
1212
end

DifferentiationInterface/src/first_order/jacobian.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
$(docstring_prepare("jacobian"; inplace=true))
88
"""
99
function prepare_jacobian(
10-
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict=Val(false)
10+
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict::Val=Val(false)
1111
) where {F,C}
1212
return prepare_jacobian_nokwarg(strict, f, backend, x, contexts...)
1313
end
1414

1515
function prepare_jacobian(
16-
f!::F, y, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict=Val(false)
16+
f!::F,
17+
y,
18+
backend::AbstractADType,
19+
x,
20+
contexts::Vararg{Context,C};
21+
strict::Val=Val(false),
1722
) where {F,C}
1823
return prepare_jacobian_nokwarg(strict, f!, y, backend, x, contexts...)
1924
end

DifferentiationInterface/src/first_order/pullback.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function prepare_pullback(
1212
x,
1313
ty::NTuple,
1414
contexts::Vararg{Context,C};
15-
strict=Val(false),
15+
strict::Val=Val(false),
1616
) where {F,C}
1717
return prepare_pullback_nokwarg(strict, f, backend, x, ty, contexts...)
1818
end
@@ -24,7 +24,7 @@ function prepare_pullback(
2424
x,
2525
ty::NTuple,
2626
contexts::Vararg{Context,C};
27-
strict=Val(false),
27+
strict::Val=Val(false),
2828
) where {F,C}
2929
return prepare_pullback_nokwarg(strict, f!, y, backend, x, ty, contexts...)
3030
end
@@ -49,7 +49,7 @@ function prepare_pullback_same_point(
4949
x,
5050
ty::NTuple,
5151
contexts::Vararg{Context,C};
52-
strict=Val(false),
52+
strict::Val=Val(false),
5353
) where {F,C}
5454
return prepare_pullback_same_point_nokwarg(strict, f, backend, x, ty, contexts...)
5555
end
@@ -61,7 +61,7 @@ function prepare_pullback_same_point(
6161
x,
6262
ty::NTuple,
6363
contexts::Vararg{Context,C};
64-
strict=Val(false),
64+
strict::Val=Val(false),
6565
) where {F,C}
6666
return prepare_pullback_same_point_nokwarg(strict, f!, y, backend, x, ty, contexts...)
6767
end

DifferentiationInterface/src/first_order/pushforward.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function prepare_pushforward(
1212
x,
1313
tx::NTuple,
1414
contexts::Vararg{Context,C};
15-
strict=Val(false),
15+
strict::Val=Val(false),
1616
) where {F,C}
1717
return prepare_pushforward_nokwarg(strict, f, backend, x, tx, contexts...)
1818
end
@@ -24,7 +24,7 @@ function prepare_pushforward(
2424
x,
2525
tx::NTuple,
2626
contexts::Vararg{Context,C};
27-
strict=Val(false),
27+
strict::Val=Val(false),
2828
) where {F,C}
2929
return prepare_pushforward_nokwarg(strict, f!, y, backend, x, tx, contexts...)
3030
end
@@ -49,7 +49,7 @@ function prepare_pushforward_same_point(
4949
x,
5050
tx::NTuple,
5151
contexts::Vararg{Context,C};
52-
strict=Val(false),
52+
strict::Val=Val(false),
5353
) where {F,C}
5454
return prepare_pushforward_same_point_nokwarg(strict, f, backend, x, tx, contexts...)
5555
end
@@ -61,7 +61,7 @@ function prepare_pushforward_same_point(
6161
x,
6262
tx::NTuple,
6363
contexts::Vararg{Context,C};
64-
strict=Val(false),
64+
strict::Val=Val(false),
6565
) where {F,C}
6666
return prepare_pushforward_same_point_nokwarg(
6767
strict, f!, y, backend, x, tx, contexts...

DifferentiationInterface/src/second_order/hessian.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$(docstring_prepare("hessian"))
77
"""
88
function prepare_hessian(
9-
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict=Val(false)
9+
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict::Val=Val(false)
1010
) where {F,C}
1111
return prepare_hessian_nokwarg(strict, f, backend, x, contexts...)
1212
end

DifferentiationInterface/src/second_order/hvp.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function prepare_hvp(
1111
x,
1212
tx::NTuple,
1313
contexts::Vararg{Context,C};
14-
strict=Val(false),
14+
strict::Val=Val(false),
1515
) where {F,C}
1616
return prepare_hvp_nokwarg(strict, f, backend, x, tx, contexts...)
1717
end
@@ -34,7 +34,7 @@ function prepare_hvp_same_point(
3434
x,
3535
tx::NTuple,
3636
contexts::Vararg{Context,C};
37-
strict=Val(false),
37+
strict::Val=Val(false),
3838
) where {F,C}
3939
return prepare_hvp_same_point_nokwarg(strict, f, backend, x, tx, contexts...)
4040
end

DifferentiationInterface/src/second_order/second_derivative.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$(docstring_prepare("second_derivative"))
77
"""
88
function prepare_second_derivative(
9-
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict=Val(false)
9+
f::F, backend::AbstractADType, x, contexts::Vararg{Context,C}; strict::Val=Val(false)
1010
) where {F,C}
1111
return prepare_second_derivative_nokwarg(strict, f, backend, x, contexts...)
1212
end

DifferentiationInterface/test/Back/ForwardDiff/test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ end
9090
# Derivative
9191
x = 1.0
9292
y = [1.0, 1.0]
93-
@test DI.overloaded_input_type(prepare_derivative_nokwarg(copy, backend, x)) ==
93+
@test DI.overloaded_input_type(prepare_derivative(copy, backend, x)) ==
9494
ForwardDiff.Dual{ForwardDiff.Tag{typeof(copy),Float64},Float64,1}
95-
@test DI.overloaded_input_type(prepare_derivative_nokwarg(copyto!, y, backend, x)) ==
95+
@test DI.overloaded_input_type(prepare_derivative(copyto!, y, backend, x)) ==
9696
Vector{ForwardDiff.Dual{ForwardDiff.Tag{typeof(copyto!),Float64},Float64,1}}
9797

9898
# Gradient

DifferentiationInterface/test/Back/ReverseDiff/test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test_differentiation(
4747

4848
# Derivative
4949
x = 1.0
50-
@test_skip DI.overloaded_input_type(prepare_derivative_nokwarg(copy, backend, x)) ==
50+
@test_skip DI.overloaded_input_type(prepare_derivative(copy, backend, x)) ==
5151
ReverseDiff.TrackedArray{Float64,Float64,1,Vector{Float64},Vector{Float64}}
5252

5353
# Gradient

0 commit comments

Comments
 (0)