Skip to content

Commit

Permalink
Rename value_and_derivatives -> value_and_derivative_and_second_deriv…
Browse files Browse the repository at this point in the history
…ative
  • Loading branch information
gerlero committed Jan 3, 2024
1 parent db8607c commit 3b7a5b5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/src/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ AbstractDifferentiation.value_and_gradient
AbstractDifferentiation.value_and_jacobian
AbstractDifferentiation.value_and_second_derivative
AbstractDifferentiation.value_and_hessian
AbstractDifferentiation.value_and_derivatives
AbstractDifferentiation.value_derivative_and_second_derivative
AbstractDifferentiation.value_gradient_and_hessian
```

Expand Down
2 changes: 1 addition & 1 deletion ext/AbstractDifferentiationForwardDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function AD.value_and_hessian(ba::AD.ForwardDiffBackend, f, x)
return DiffResults.value(result), (DiffResults.hessian(result),)
end

function AD.value_and_derivatives(ba::AD.ForwardDiffBackend, f, x::Real)
function AD.value_derivative_and_second_derivative(ba::AD.ForwardDiffBackend, f, x::Real)
T = typeof(ForwardDiff.Tag(f, typeof(x)))
xdual = ForwardDiff.Dual{T}(x, one(x))
T2 = typeof(ForwardDiff.Tag(f, typeof(xdual)))
Expand Down
4 changes: 2 additions & 2 deletions src/AbstractDifferentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ function value_and_hessian(ab::HigherOrderBackend, f, x)
end

"""
AD.value_and_derivatives(ab::AD.AbstractBackend, f, x)
AD.value_derivative_and_second_derivative(ab::AD.AbstractBackend, f, x)
Return the tuple `(v, d, d2)` of the function value `v = f(x)` and the first and second derivatives `d = AD.derivative(ab, f, x)` and `d2 = AD.secondderivative(ab, f, x)`.
"""
function value_and_derivatives(ab::AbstractBackend, f, x)
function value_derivative_and_second_derivative(ab::AbstractBackend, f, x)
if x isa Tuple
# only support computation of Hessian for functions with single input argument
x = only(x)

Check warning on line 216 in src/AbstractDifferentiation.jl

View check run for this annotation

Codecov / codecov/patch

src/AbstractDifferentiation.jl#L216

Added line #L216 was not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion test/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function test_second_derivatives(backend; multiple_inputs=false, test_types=true
end
@test valscalar == fder(xscalar, yscalar)
@test norm.(dder2 .- dder1) == (0,)
valscalar, der, dder3 = AD.value_and_derivatives(
valscalar, der, dder3 = AD.value_derivative_and_second_derivative(
backend, x -> fder(x, yscalar), xscalar
)
if test_types
Expand Down

0 comments on commit 3b7a5b5

Please sign in to comment.