Skip to content

Commit

Permalink
Merge pull request #3625 from JuliaReach/auto-juliaformatter-pr
Browse files Browse the repository at this point in the history
Automatic JuliaFormatter.jl run
  • Loading branch information
schillic authored Jul 27, 2024
2 parents 6028ccb + 7e4ed70 commit a5a4046
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/ConcreteOperations/minkowski_sum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ function minkowski_sum(X::AbstractSingleton, Y::AbstractSingleton)
return Singleton(element(X) + element(Y))
end


function _minkowski_sum_vpolygon(P::LazySet, Q::LazySet)
return minkowski_sum(convert(VPolygon, P), convert(VPolygon, Q))
end
Expand Down
5 changes: 3 additions & 2 deletions src/Sets/Hyperplane/init_SymEngine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ function free_symbols(expr::Expr, ::Type{<:Hyperplane})
lhs = convert(SymEngine.Basic, expr.args[1])

# treats the 4 in :(2*x1 = 4)
rhs = :args in fieldnames(typeof(expr.args[2])) ? convert(SymEngine.Basic, expr.args[2].args[2]) :
convert(SymEngine.Basic, expr.args[2])
rhs = :args in fieldnames(typeof(expr.args[2])) ?
convert(SymEngine.Basic, expr.args[2].args[2]) :
convert(SymEngine.Basic, expr.args[2])
return SymEngine.free_symbols(lhs - rhs)
end

Expand Down
6 changes: 4 additions & 2 deletions src/Sets/Zonotope/split.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ function load_StaticArraysCore_split()

function _split_ret(Z₁::Zonotope{N,SV,SM},
Z₂::Zonotope{N,SV,SM}) where {N,n,p,SV<:MVector{n,N},SM<:MMatrix{n,p,N}}
Z₁ = Zonotope(StaticArraysCore.SVector{n}(Z₁.center), StaticArraysCore.SMatrix{n,p}(Z₁.generators))
Z₂ = Zonotope(StaticArraysCore.SVector{n}(Z₂.center), StaticArraysCore.SMatrix{n,p}(Z₂.generators))
Z₁ = Zonotope(StaticArraysCore.SVector{n}(Z₁.center),
StaticArraysCore.SMatrix{n,p}(Z₁.generators))
Z₂ = Zonotope(StaticArraysCore.SVector{n}(Z₂.center),
StaticArraysCore.SMatrix{n,p}(Z₂.generators))
return Z₁, Z₂
end
end
Expand Down
10 changes: 5 additions & 5 deletions test/Interfaces/SymEngine.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# _is_linearcombination
@test LazySets._is_linearcombination(:(2*x1 - 4))
@test LazySets._is_linearcombination(:(6.1 - 5.3*f - 0.1*g))
@test !LazySets._is_linearcombination(:(2*x1^2))
@test !LazySets._is_linearcombination(:(x1^2 - 4*x2 + x3 + 2))
@test LazySets._is_linearcombination(:(2 * x1 - 4))
@test LazySets._is_linearcombination(:(6.1 - 5.3 * f - 0.1 * g))
@test !LazySets._is_linearcombination(:(2 * x1^2))
@test !LazySets._is_linearcombination(:(x1^2 - 4 * x2 + x3 + 2))

# _free_symbols
@test LazySets._free_symbols(:(x1 = 1)) == [SymEngine.Basic(:(x1))]
@test LazySets._free_symbols(:(2*x2 <= 4)) == [SymEngine.Basic(:(x2))]
@test LazySets._free_symbols(:(2 * x2 <= 4)) == [SymEngine.Basic(:(x2))]
@test_throws ErrorException LazySets._free_symbols(:(x3 != 4))
16 changes: 8 additions & 8 deletions test/Sets/HalfSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,24 +257,24 @@ for N in [Float64]
# _is_halfspace
@test all(LazySets._is_halfspace.([:(x1 <= 0), :(x1 < 0), :(x1 > 0), :(x1 >= 0)]))
@test !LazySets._is_halfspace(:(x1 = 0))
@test LazySets._is_halfspace(:(2*x1 <= 4))
@test LazySets._is_halfspace(:(6.1 <= 5.3*f - 0.1*g))
@test !LazySets._is_halfspace(:(2*x1^2 <= 4))
@test !LazySets._is_halfspace(:(x1^2 > 4*x2 - x3))
@test LazySets._is_halfspace(:(x1 > 4*x2 - x3))
@test LazySets._is_halfspace(:(2 * x1 <= 4))
@test LazySets._is_halfspace(:(6.1 <= 5.3 * f - 0.1 * g))
@test !LazySets._is_halfspace(:(2 * x1^2 <= 4))
@test !LazySets._is_halfspace(:(x1^2 > 4 * x2 - x3))
@test LazySets._is_halfspace(:(x1 > 4 * x2 - x3))

# convert
H = convert(HalfSpace, :(x1 <= -0.03))
@test H == HalfSpace([1.0], -0.03)
@test H == HalfSpace([1.0], -0.03)
H = convert(HalfSpace, :(x1 < -0.03))
@test H == HalfSpace([1.0], -0.03)
H = convert(HalfSpace, :(x1 > -0.03))
@test H == HalfSpace([-1.0], 0.03)
H = convert(HalfSpace, :(x1 >= -0.03))
@test H == HalfSpace([-1.0], 0.03)
H = convert(HalfSpace, :(x1 + x2 <= 2*x4 + 6))
H = convert(HalfSpace, :(x1 + x2 <= 2 * x4 + 6))
@test H == HalfSpace([1.0, 1.0, -2.0], 6.0)
H = convert(HalfSpace, :(x1 + x2 <= 2*x4 + 6), vars=SymEngine.Basic[:x1, :x2, :x3, :x4])
H = convert(HalfSpace, :(x1 + x2 <= 2 * x4 + 6); vars=SymEngine.Basic[:x1, :x2, :x3, :x4])
@test H == HalfSpace([1.0, 1.0, 0.0, -2.0], 6.0)
end
end
Expand Down
14 changes: 7 additions & 7 deletions test/Sets/Hyperplane.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,20 @@ for N in [Float64]
# _is_halfspace
@test LazySets._is_hyperplane(:(x1 = 0))
@test !LazySets._is_hyperplane(:(x1 <= 0))
@test LazySets._is_hyperplane(:(2*x1 = 4))
@test LazySets._is_hyperplane(:(6.1 = 5.3*f - 0.1*g))
@test !LazySets._is_hyperplane(:(2*x1^2 = 4))
@test !LazySets._is_hyperplane(:(x1^2 = 4*x2 - x3))
@test LazySets._is_hyperplane(:(x1 = 4*x2 - x3))
@test LazySets._is_hyperplane(:(2 * x1 = 4))
@test LazySets._is_hyperplane(:(6.1 = 5.3 * f - 0.1 * g))
@test !LazySets._is_hyperplane(:(2 * x1^2 = 4))
@test !LazySets._is_hyperplane(:(x1^2 = 4 * x2 - x3))
@test LazySets._is_hyperplane(:(x1 = 4 * x2 - x3))

# convert
H = convert(Hyperplane, :(x1 = -0.03))
@test H == Hyperplane([1.0], -0.03)
H = convert(Hyperplane, :(x1 + 0.03 = 0))
@test H == Hyperplane([1.0], -0.03)
H = convert(Hyperplane, :(x1 + x2 = 2*x4 + 6))
H = convert(Hyperplane, :(x1 + x2 = 2 * x4 + 6))
@test H == Hyperplane([1.0, 1.0, -2.0], 6.0)
H = convert(Hyperplane, :(x1 + x2 = 2*x4 + 6), vars=SymEngine.Basic[:x1, :x2, :x3, :x4])
H = convert(Hyperplane, :(x1 + x2 = 2 * x4 + 6); vars=SymEngine.Basic[:x1, :x2, :x3, :x4])
@test H == Hyperplane([1.0, 1.0, 0.0, -2.0], 6.0)
end
end
Expand Down

0 comments on commit a5a4046

Please sign in to comment.