Skip to content

Commit

Permalink
Update runtests.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Sep 11, 2024
1 parent bf85245 commit bdc15d1
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,46 +111,46 @@ function test_getter_setter(nlp)
@test typeof(get_adbackend(nlp).hessian_backend) <: ADNLPModels.ReverseDiffADHessian
end

ZygoteAD() = ADNLPModels.ADModelBackend(
ADNLPModels.ZygoteADGradient(),
ADNLPModels.GenericForwardDiffADHvprod(),
ADNLPModels.ZygoteADJprod(),
ADNLPModels.ZygoteADJtprod(),
ADNLPModels.ZygoteADJacobian(0),
ADNLPModels.ZygoteADHessian(0),
ADNLPModels.ForwardDiffADGHjvprod(),
ADNLPModels.EmptyADbackend(),
ADNLPModels.EmptyADbackend(),
ADNLPModels.EmptyADbackend(),
ADNLPModels.EmptyADbackend(),
ADNLPModels.EmptyADbackend(),
)
# ZygoteAD() = ADNLPModels.ADModelBackend(
# ADNLPModels.ZygoteADGradient(),
# ADNLPModels.GenericForwardDiffADHvprod(),
# ADNLPModels.ZygoteADJprod(),
# ADNLPModels.ZygoteADJtprod(),
# ADNLPModels.ZygoteADJacobian(0),
# ADNLPModels.ZygoteADHessian(0),
# ADNLPModels.ForwardDiffADGHjvprod(),
# ADNLPModels.EmptyADbackend(),
# ADNLPModels.EmptyADbackend(),
# ADNLPModels.EmptyADbackend(),
# ADNLPModels.EmptyADbackend(),
# ADNLPModels.EmptyADbackend(),
# )

function test_autodiff_backend_error()
@testset "Error without loading package - $backend" for backend in [:ZygoteAD]
adbackend = eval(backend)()
@test_throws ArgumentError gradient(adbackend.gradient_backend, sum, [1.0])
@test_throws ArgumentError gradient!(adbackend.gradient_backend, [1.0], sum, [1.0])
@test_throws ArgumentError jacobian(adbackend.jacobian_backend, identity, [1.0])
@test_throws ArgumentError hessian(adbackend.hessian_backend, sum, [1.0])
@test_throws ArgumentError Jprod!(
adbackend.jprod_backend,
[1.0],
[1.0],
identity,
[1.0],
Val(:c),
)
@test_throws ArgumentError Jtprod!(
adbackend.jtprod_backend,
[1.0],
[1.0],
identity,
[1.0],
Val(:c),
)
end
end
# function test_autodiff_backend_error()
# @testset "Error without loading package - $backend" for backend in [:ZygoteAD]
# adbackend = eval(backend)()
# @test_throws ArgumentError gradient(adbackend.gradient_backend, sum, [1.0])
# @test_throws ArgumentError gradient!(adbackend.gradient_backend, [1.0], sum, [1.0])
# @test_throws ArgumentError jacobian(adbackend.jacobian_backend, identity, [1.0])
# @test_throws ArgumentError hessian(adbackend.hessian_backend, sum, [1.0])
# @test_throws ArgumentError Jprod!(
# adbackend.jprod_backend,
# [1.0],
# [1.0],
# identity,
# [1.0],
# Val(:c),
# )
# @test_throws ArgumentError Jtprod!(
# adbackend.jtprod_backend,
# [1.0],
# [1.0],
# identity,
# [1.0],
# Val(:c),
# )
# end
# end

# Test the argument error without loading the packages
test_autodiff_backend_error()
Expand Down

0 comments on commit bdc15d1

Please sign in to comment.