From a86acd3978f9b289e03d3559456fea66e6ad7218 Mon Sep 17 00:00:00 2001 From: lassepe Date: Mon, 8 Jan 2024 13:02:31 +0100 Subject: [PATCH] Fix typo in testing of infeasible parameters --- test/runtests.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index e232491..a9c0839 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,7 +15,7 @@ using FiniteDiff: FiniteDiff lower_bounds = [-Inf, -Inf, 0, 0] upper_bounds = [Inf, Inf, Inf, Inf] problem = ParametricMCPs.ParametricMCP(f, lower_bounds, upper_bounds, parameter_dimension) - problem_no_jacobian = ParametricMCPs.ParametricMCP(f, lower_bounds, upper_bounds, parameter_dimension; compute_sensitivities = false) + problem_no_jacobian = ParametricMCPs.ParametricMCP(f, lower_bounds, upper_bounds, parameter_dimension; compute_sensitivities=false) feasible_parameters = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [rand(rng, 2) for _ in 1:10]...] infeasible_parameters = -feasible_parameters @@ -26,7 +26,7 @@ using FiniteDiff: FiniteDiff @test solution.z[1:2] ≈ θ end - for θ in feasible_parameters + for θ in infeasible_parameters solution = ParametricMCPs.solve(problem, θ) @test norm(solution.z[1:2] - θ) <= norm(θ) end @@ -42,11 +42,11 @@ using FiniteDiff: FiniteDiff ∇_autodiff_reverse = only(Zygote.gradient(dummy_pipeline, θ)) ∇_autodiff_forward = only(Zygote.gradient(θ -> Zygote.forwarddiff(dummy_pipeline, θ), θ)) ∇_finitediff = FiniteDiff.finite_difference_gradient(dummy_pipeline, θ) - @test isapprox(∇_autodiff_reverse, ∇_finitediff; atol = 1e-4) - @test isapprox(∇_autodiff_reverse, ∇_autodiff_forward; atol = 1e-4) + @test isapprox(∇_autodiff_reverse, ∇_finitediff; atol=1e-4) + @test isapprox(∇_autodiff_reverse, ∇_autodiff_forward; atol=1e-4) end - end - + end + @testset "missing jacobian" begin function dummy_pipeline(θ, problem) solution = ParametricMCPs.solve(problem, θ) @@ -54,5 +54,5 @@ using FiniteDiff: FiniteDiff end @test_throws ArgumentError Zygote.gradient(θ -> dummy_pipeline(θ, problem_no_jacobian), feasible_parameters[1]) - end + end end