From 9760ada06f39d9963528135e36e498e287cf439c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Thi=C3=A9baut?= Date: Mon, 23 Oct 2023 17:04:38 +0200 Subject: [PATCH] Fix typos detected by spell-checking GitHub Action --- .github/actions/spelling/allow.txt | 1 + src/PRIMA.jl | 10 +++++----- test/runtests.jl | 32 +++++++++++++++--------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt index 7ab0963..5165ba3 100644 --- a/.github/actions/spelling/allow.txt +++ b/.github/actions/spelling/allow.txt @@ -1103,6 +1103,7 @@ isrvub isscalar isspace isstruct +issuccess issymmetric istp istr diff --git a/src/PRIMA.jl b/src/PRIMA.jl index cdb67a9..04813d9 100644 --- a/src/PRIMA.jl +++ b/src/PRIMA.jl @@ -28,7 +28,7 @@ An object, say `info`, of this type has the following properties: info.nl_ineq # non-linear inequality constraints, empty vector if none Call `issuccess(info)` or `issuccess(info.status)` to check whether algorithm -was sucessful. Call `PRIMA.reason(info)` or `PRIMA.reason(info.status)` to +was successful. Call `PRIMA.reason(info)` or `PRIMA.reason(info.status)` to retrieve a textual description of the algorithm termination. """ @@ -62,7 +62,7 @@ LinearAlgebra.issuccess(status::Status) = PRIMA.reason(info::PRIMA.Info) -> str PRIMA.reason(status::PRIMA.Status) -> str -yield a textual message explaining `info.statu` or `status`, the status code +yield a textual message explaining `info.status` or `status`, the status code returned by one of the PRIMA optimizers. """ @@ -521,7 +521,7 @@ function cobyla!(f, x::DenseVector{Cdouble}; A_eq, b_eq = _get_linear_constraints(linear_eq, n, scl) A_ineq, b_ineq = _get_linear_constraints(linear_ineq, n, scl) - # Alocate vector to store all non-linear constraints (the non-linear + # Allocate vector to store all non-linear constraints (the non-linear # equalities being implemented as 2 inequalities each). nl_all = Vector{Cdouble}(undef, 2*length(nl_eq) + length(nl_ineq)) @@ -655,7 +655,7 @@ struct ObjFun{F,E,I} c_ineq::I # callable implementing non-linear inequalities as `c_ineq(x) ≤ 0` n_ineq::Int # number of non-linear inequalities scl::Vector{Cdouble} # scaling factors or empty - wrk::Vector{Cdouble} # workspace for variables + x::Vector{Cdouble} # workspace for variables end unconstrained(x::AbstractVector{T}) where {T} = NullVector{T}() @@ -781,7 +781,7 @@ function unsafe_call(f::ObjFun, x_ptr::Ptr{Cdouble}, c_ptr::Ptr{Cdouble}) end function get_variables(f::ObjFun, x_ptr::Ptr{Cdouble}) - n, x, scl = f.n, f.wrk, f.scl + n, x, scl = f.n, f.x, f.scl length(x) == n || corrupted_structure("invalid number of variables") if isempty(scl) # No scaling of variables. diff --git a/test/runtests.jl b/test/runtests.jl index 388a968..65d0ff1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -18,20 +18,20 @@ optimizer(algo::Symbol) = algo === :prima ? PRIMA.prima : error("unknown optimizer `:$algo`") -prt_1(x::AbstractVector, info::PRIMA.Info) = prt_1(stdout, x, info) -function prt_1(io::IO, x::AbstractVector, info::PRIMA.Info) +print_1(x::AbstractVector, info::PRIMA.Info) = print_1(stdout, x, info) +function print_1(io::IO, x::AbstractVector, info::PRIMA.Info) msg = PRIMA.reason(info) println(io, "x = $x, f(x) = $(info.fx), status = $(info.status), msg = '$msg', evals = $(info.nf)") end -prt_2(x::AbstractVector, info::PRIMA.Info) = prt_2(stdout, x, info) -function prt_2(io::IO, x::AbstractVector, info::PRIMA.Info) +print_2(x::AbstractVector, info::PRIMA.Info) = print_2(stdout, x, info) +function print_2(io::IO, x::AbstractVector, info::PRIMA.Info) msg = PRIMA.reason(info) println(io, "x = $x, f(x) = $(info.fx), cstrv = $(info.cstrv), status = $(info.status), msg = '$msg', evals = $(info.nf)") end -prt_3(x::AbstractVector, info::PRIMA.Info) = prt_3(stdout, x, info) -function prt_3(io::IO, x::AbstractVector, info::PRIMA.Info) +print_3(x::AbstractVector, info::PRIMA.Info) = print_3(stdout, x, info) +function print_3(io::IO, x::AbstractVector, info::PRIMA.Info) msg = PRIMA.reason(info) println("x = $x, f(x) = $(info.fx), cstrv = $(info.cstrv), c(x) = $(info.nl_ineq), status = $(info.status), msg = '$msg', evals = $(info.nf)") end @@ -97,7 +97,7 @@ end kwds = (rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf, maxfun = 200n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT) x, info = @inferred PRIMA.newuoa(f, x0; kwds...) - prt_1(x, info) + print_1(x, info) @test x ≈ [3,2] atol=2e-2 rtol=0 @test f(x) ≈ info.fx @test x0 == x0_sav @@ -117,7 +117,7 @@ end kwds = (rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf, maxfun = 200n, iprint = PRIMA.MSG_EXIT) x, info = @inferred PRIMA.uobyqa(f, x0; kwds...) - prt_1(x, info) + print_1(x, info) @test x ≈ [3,2] atol=2e-2 rtol=0 @test f(x) ≈ info.fx @test x0 == x0_sav @@ -134,7 +134,7 @@ end rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf, maxfun = 200n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT) x, info = @inferred PRIMA.bobyqa(f, x0; kwds...) - prt_1(x, info) + print_1(x, info) @test x ≈ [3,2] atol=2e-2 rtol=0 @test f(x) ≈ info.fx @test x0 == x0_sav @@ -158,7 +158,7 @@ end # First call with just the number of non-linear inequality constraints. x, info = @inferred PRIMA.cobyla(f, x0; kwds..., nonlinear_ineq = c_ineq) - prt_3(x, info) + print_3(x, info) @test x ≈ [3,2] atol=2e-2 rtol=0 @test f(x) ≈ info.fx @test x0 == x0_sav @@ -188,7 +188,7 @@ end rhobeg = 1.0, rhoend = 1e-3, ftarget = -Inf, maxfun = 200*n, npt = 2n + 1, iprint = PRIMA.MSG_EXIT) x, info = @inferred PRIMA.lincoa(f, x0; kwds...) - prt_2(x, info) + print_2(x, info) @test x ≈ [3,2] atol=2e-2 rtol=0 @test f(x) ≈ info.fx @test x0 == x0_sav @@ -279,7 +279,7 @@ end else continue end - prt_1(x, info) + print_1(x, info) @test x ≈ [1,1] rtol=0 atol=(optim == :cobyla ? 3e-2 : 2e-2) @test f(x) ≈ info.fx @@ -301,7 +301,7 @@ end else continue end - prt_1(x, info) + print_1(x, info) @test x ≈ [1.095247,1.2] rtol=0 atol=2e-2 @test f(x) ≈ info.fx end @@ -320,7 +320,7 @@ end else continue end - prt_1(x, info) + print_1(x, info) @test x ≈ [1.0,1.0] rtol=0 atol=(optim == :cobyla ? 3e-2 : 2e-2) @test f(x) ≈ info.fx @@ -337,7 +337,7 @@ end else continue end - prt_1(x, info) + print_1(x, info) @test x ≈ [1.0,1.0] rtol=0 atol=(optim == :cobyla ? 3e-2 : 2e-2) @test f(x) ≈ info.fx @@ -355,7 +355,7 @@ end else continue end - prt_1(x, info) + print_1(x, info) @test x ≈ [1.441832,2.077557] rtol=0 atol=(optim == :cobyla ? 3e-2 : 2e-2) @test f2(x) ≈ info.fx end