Skip to content

Update to JuliaFormatter v2 #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
shell: julia --color=yes {0}
run: |
using Pkg
Pkg.add(PackageSpec(name="JuliaFormatter", version="1"))
Pkg.add(PackageSpec(name="JuliaFormatter", version="2"))
using JuliaFormatter
format("src", verbose=true)
format("test", verbose=true)
Expand Down
7 changes: 3 additions & 4 deletions src/Bridges/Constraint/image.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,9 @@ function MOI.get(
MOI.get(model, attr, bridge.zero_constraint),
)
end
funcs =
MOI.Utilities.eachscalar.(
MOI.get.(model, MOI.ConstraintFunction(), bridge.constraints)
)
funcs = MOI.Utilities.eachscalar.(
MOI.get.(model, MOI.ConstraintFunction(), bridge.constraints),
)
z_idx = 0
return MOI.Utilities.vectorize(
map(eachindex(bridge.first)) do i
Expand Down
2 changes: 1 addition & 1 deletion src/Certificate/Sparsity/xor_space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ end
function XORSpace(n)
return XORSpace{appropriate_type(n)}(n)
end
b(x) = bitstring(x)[end-5:end]
b(x) = bitstring(x)[(end-5):end]
e_i(T, i) = (one(T) << (i - 1))
has_bit(x, i) = !iszero(x & e_i(typeof(x), i))
function Base.push!(xs::XORSpace{T}, x::T) where {T}
Expand Down
2 changes: 1 addition & 1 deletion src/Certificate/Symmetry/block_diag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function block_diag(As, d)
end
V *= _V
end
U[:, offset.+eachindex(v)] = V
U[:, offset .+ eachindex(v)] = V
offset += length(v)
end
if offset == n
Expand Down
15 changes: 6 additions & 9 deletions src/Certificate/newton_polytope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@ function _multiplier_maxdegree(maxdegree, g::SA.AlgebraElement, vars)
end

function _multiplier_deg_range(range, g::SA.AlgebraElement, vars)
return _multiplier_mindegree(minimum(range), g, vars):_multiplier_maxdegree(
maximum(range),
return _multiplier_mindegree(
minimum(range),
g,
vars,
)
):_multiplier_maxdegree(maximum(range), g, vars)
end

# Cheap approximation of the convex hull as the approximation of:
Expand Down Expand Up @@ -344,7 +344,7 @@ function putinar_degree_bounds(
p,
gs,
minus_degrange,
-maxdegree:0,
(-maxdegree):0,
)
isnothing(d) ? d : -d
else
Expand All @@ -365,7 +365,7 @@ function putinar_degree_bounds(
p,
gs,
minus_degrange,
-maxdegree:0,
(-maxdegree):0,
)
else
0
Expand Down Expand Up @@ -837,8 +837,5 @@ function half_newton_polytope(basis::MB.SubBasis, args...)
end

function monomials_half_newton_polytope(monos, args...)
return half_newton_polytope(
MB.SubBasis{MB.Monomial}(monos),
args...,
).monomials
return half_newton_polytope(MB.SubBasis{MB.Monomial}(monos), args...).monomials
end
2 changes: 1 addition & 1 deletion test/Tests/chebyshev.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function chebyshev_test(optimizer, config::MOI.Test.Config)

@polyvar x

Z = monomials((x,), 0:ndeg-1)
Z = monomials((x,), 0:(ndeg-1))

model = _model(optimizer)

Expand Down
2 changes: 1 addition & 1 deletion test/Tests/sosdemo5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function sosdemo5_test(optimizer, config::MOI.Test.Config, feasible::Bool, γ)
# -- r's -- : constant sum of squares
Z = monomials(x, 0)
#r = Matrix{GramMatrix{JuMP.VariableRef}}(4,4) # FIXME doesn't work with 1x1 SDP matrix :(
@variable model r[i = 1:4, j = (i+1):4] >= 0
@variable model r[i=1:4, j=(i+1):4] >= 0

# Constraint : -sum(Qi(x)*Ai(x)) - sum(rij*Ai(x)*Aj(x)) + I(x) >= 0
expr = 0
Expand Down
21 changes: 9 additions & 12 deletions test/certificate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,13 @@ function test_putinar_ijk(i, j, k, default::Bool, post_filter::Bool = default)
poly = x^(2i) + y^(2j + 1)
domain = @set y^(2k + 1) >= 0
if default
certificate =
JuMP.moi_set(
SOSCone(),
MB.SubBasis{MB.Monomial}(monomials(poly)),
MB.FullBasis{MB.Monomial,MP.monomial_type(poly)}(),
MB.FullBasis{MB.Monomial,MP.monomial_type(poly)}();
domain,
).certificate
certificate = JuMP.moi_set(
SOSCone(),
MB.SubBasis{MB.Monomial}(monomials(poly)),
MB.FullBasis{MB.Monomial,MP.monomial_type(poly)}(),
MB.FullBasis{MB.Monomial,MP.monomial_type(poly)}();
domain,
).certificate
else
newton = Certificate.NewtonDegreeBounds(tuple())
if post_filter
Expand All @@ -351,10 +350,8 @@ function test_putinar_ijk(i, j, k, default::Bool, post_filter::Bool = default)
@test isempty(monos)
else
w = post_filter ? v[2:2] : v
@test monos == MP.monomials(
w,
max(0, (post_filter ? j : min(i, j)) - k):(j-k),
)
@test monos ==
MP.monomials(w, max(0, (post_filter ? j : min(i, j))-k):(j-k))
end
end
icert = Certificate.ideal_certificate(certificate)
Expand Down
1 change: 1 addition & 0 deletions test/equalitypolyconstr.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@testset "Polynomial equality constraint with domain with $(factory.optimizer_constructor)" for factory in
sdp_factories

@polyvar(x, y)

m = SOSModel(factory)
Expand Down
2 changes: 1 addition & 1 deletion test/segfault.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ for (gam, expected) in [(0.8723, :Infeasible), (0.8724, :Optimal)]

# -- r's -- : constant sum of squares
Z = monomials(x, 0)
@variable m r[i = 1:4, j = (i+1):4] >= 0
@variable m r[i=1:4, j=(i+1):4] >= 0

# Constraint : -sum(Qi(x)*Ai(x)) - sum(rij*Ai(x)*Aj(x)) + I(x) >= 0
expr = 0
Expand Down
1 change: 1 addition & 0 deletions test/simplepolysos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Semidefinite optimization and convex algebraic geometry SIAM 2013
@testset "Example 3.35 with $(factory.optimizer_constructor)" for factory in
sdp_factories

@polyvar x
m = SOSModel(factory)
@constraint m x^4 + 4x^3 + 6x^2 + 4x + 5 in SOSCone() # equivalent to >= 0
Expand Down
1 change: 1 addition & 0 deletions test/sosquartic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@testset "SOSquartic with $(factory.optimizer_constructor)" for factory in
sdp_factories

@polyvar x y
m = SOSModel(factory)
p = x^4 - y^4
Expand Down
10 changes: 7 additions & 3 deletions test/sparsity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,13 @@ function wml19()
certificate,
),
) == Set(
monomial_vector.([
[x[1]^2 * x[2]^2, x[1] * x[2]^2, 1, x[1]^2 * x[2], x[1] * x[2]],
]),
monomial_vector.([[
x[1]^2 * x[2]^2,
x[1] * x[2]^2,
1,
x[1]^2 * x[2],
x[1] * x[2],
],]),
)
end
end
Expand Down
Loading