Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Lorenz <benlorenz@users.noreply.github.com>
  • Loading branch information
lkastner and benlorenz committed Oct 1, 2021
1 parent 79bcd35 commit 9bc4c32
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Polytopes/Polyhedron/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Polyhedron(A::Union{Oscar.MatElem,AbstractMatrix}, b) = Polyhedron((A, b))

function Polyhedron(I::Union{HalfspaceIterator, Tuple{<:Union{Oscar.MatElem, AbstractMatrix}, Any}}, E::Union{Nothing, HalfspaceIterator, Tuple{<:Union{Oscar.MatElem, AbstractMatrix}, Any}} = nothing; non_redundant::Bool = false)
IM = -affine_matrix_for_polymake(I)
EM = isnothing(E) || _isempty(E) ? Polymake.Matrix{Polymake.Rational}(undef, 0, size(IM, 2)) : affine_matrix_for_polymake(E)
EM = isnothing(E) || _isempty_halfspace(E) ? Polymake.Matrix{Polymake.Rational}(undef, 0, size(IM, 2)) : affine_matrix_for_polymake(E)

if non_redundant
return Polyhedron(Polymake.polytope.Polytope{Polymake.Rational}(FACETS = IM, AFFINE_HULL = EM))
Expand Down
4 changes: 2 additions & 2 deletions src/Polytopes/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function Polymake.Matrix{Polymake.Rational}(x::Union{Oscar.fmpq_mat,AbstractMatr
return res
end

_isempty(x::Pair{<:Union{Oscar.MatElem, AbstractMatrix}, Any}) = isempty(x[1])
_isempty(x) = isempty(x)
_isempty_halfspace(x::Pair{<:Union{Oscar.MatElem, AbstractMatrix}, Any}) = isempty(x[1])
_isempty_halfspace(x) = isempty(x)

import Base: convert

Expand Down
3 changes: 1 addition & 2 deletions test/Polytopes/Polyhedron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
square = cube(2)
C1 = cube(2, 0, 1)
Pos = Polyhedron([-1 0 0; 0 -1 0; 0 0 -1], [0,0,0])
# TODO:
# @test Polyhedron(([-1 0 0; 0 -1 0; 0 0 -1], [0,0,0]); non_redundant = true) == Pos
@test Polyhedron(([-1 0 0; 0 -1 0; 0 0 -1], [0,0,0]); non_redundant = true) == Pos
L = Polyhedron([-1 0 0; 0 -1 0], [0,0])
point = convex_hull([0 1 0])
s = simplex(2)
Expand Down

0 comments on commit 9bc4c32

Please sign in to comment.