Skip to content

Commit

Permalink
adapt to renamed kwarg in 'Polyhedra.removeredundancy' ('ztol' -> 'tol')
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jan 20, 2025
1 parent 404e940 commit 2790ae4
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ConcreteOperations/intersection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ A `VPolytope`.
### Notes
If `prunefunc` is `nothing`, this implementation sets it to
`(X -> removevredundancy!(X; ztol=_ztol(eltype(P1))))`.
`(X -> removevredundancy!(X; tol=_ztol(eltype(P1))))`.
"""
function intersection(P1::Union{VPolygon,VPolytope},
P2::Union{VPolygon,VPolytope};
Expand Down Expand Up @@ -578,7 +578,7 @@ function intersection(P1::Union{VPolygon,VPolytope},

N = promote_type(eltype(P1), eltype(P2))
if isnothing(prunefunc)
prunefunc = (X -> removevredundancy!(X; ztol=_ztol(N)))
prunefunc = (X -> _removeredundancy!(X; N=N))
end
prunefunc(Pint)

Expand Down
13 changes: 13 additions & 0 deletions src/Initialization/init_Polyhedra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ function _is_polyhedra_backend(backend::Polyhedra.Library)
return true
end

# in v0.8.0, `Polyhedra` renamed the kwarg `ztol` to `tol`
@static if hasmethod(Polyhedra.detecthlinearity, (Polyhedra.HRepresentation, Any), (:ztol,))
function _removeredundancy!(X; N)
return removevredundancy!(X; ztol=_ztol(N))
end
else
@assert hasmethod(Polyhedra.detecthlinearity, (Polyhedra.HRepresentation, Any), (:tol,))

function _removeredundancy!(X; N)
return removevredundancy!(X; tol=_ztol(N))
end
end

eval(load_polyhedra_mesh())
eval(load_Polyhedra_polyhedron())

Expand Down
13 changes: 13 additions & 0 deletions src/Sets/HPolytope/init_Polyhedra.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
eval(load_Polyhedra_convert_HPolytope())
eval(load_Polyhedra_HPolytope())

# in v0.8.0, `Polyhedra` renamed the kwarg `ztol` to `tol`
@static if hasmethod(Polyhedra.detecthlinearity, (Polyhedra.HRepresentation, Any), (:ztol,))
function _removeredundancy!(X; N)
return removevredundancy!(X; ztol=_ztol(N))
end
else
@assert hasmethod(Polyhedra.detecthlinearity, (Polyhedra.HRepresentation, Any), (:tol,))

function _removeredundancy!(X; N)
return removevredundancy!(X; tol=_ztol(N))
end
end
2 changes: 1 addition & 1 deletion src/Sets/HPolytope/vertices_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function vertices_list(P::HPolytope; backend=nothing, prune::Bool=true)
end
Q = Polyhedra.polyhedron(P; backend=backend)
if prune
Polyhedra.removevredundancy!(Q; ztol=_ztol(N))
_removeredundancy!(Q; N=N)
end
return collect(Polyhedra.points(Q))
end
13 changes: 13 additions & 0 deletions src/Sets/VPolytope/init_Polyhedra.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
eval(load_Polyhedra_VPolytope())
eval(load_Polyhedra_polyhedron())

# in v0.8.0, `Polyhedra` renamed the kwarg `ztol` to `tol`
@static if hasmethod(Polyhedra.detecthlinearity, (Polyhedra.HRepresentation, Any), (:ztol,))
function _removeredundancy!(X; N)
return removevredundancy!(X; ztol=_ztol(N))
end
else
@assert hasmethod(Polyhedra.detecthlinearity, (Polyhedra.HRepresentation, Any), (:tol,))

function _removeredundancy!(X; N)
return removevredundancy!(X; tol=_ztol(N))
end
end
2 changes: 1 addition & 1 deletion src/Sets/VPolytope/remove_redundant_vertices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function remove_redundant_vertices(P::VPolytope; backend=nothing, solver=nothing
vQ = Polyhedra.vrep(Q)
Polyhedra.setvrep!(Q, Polyhedra.removevredundancy(vQ, solver))
else
Polyhedra.removevredundancy!(Q; ztol=_ztol(N))
_removeredundancy!(Q; N=N)
end
return VPolytope(Q)
end

0 comments on commit 2790ae4

Please sign in to comment.