Skip to content

Commit

Permalink
tests: move some helper functions to if block to avoid warnings on du…
Browse files Browse the repository at this point in the history
…plicate include
  • Loading branch information
benlorenz committed Oct 29, 2024
1 parent 45b79ff commit aa8d4b6
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions test/PolyhedralGeometry/setup_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ if !isdefined(Main, :_prepare_scalar_types)
KK, (a1, a2) = embedded_number_field([x^2 - 2, x^3 - 5], [(0, 2), (0, 2)])
return [(f, elem_type(f)) for f in (QQ, K, KK)]
end
end

function _check_im_perm_rows(inc::IncidenceMatrix, o)
oinc = incidence_matrix(o)
nr, nc = size(inc)
(nr, nc) == size(oinc) &&
issetequal(Polymake.row.(Ref(inc), 1:nr),
Polymake.row.(Ref(oinc), 1:nr))
end
function _check_im_perm_rows(inc::IncidenceMatrix, o)
oinc = incidence_matrix(o)
nr, nc = size(inc)
(nr, nc) == size(oinc) &&
issetequal(Polymake.row.(Ref(inc), 1:nr),
Polymake.row.(Ref(oinc), 1:nr))
end

_matrix_from_property(b::SubObjectIterator{<:Union{LinearHalfspace, LinearHyperplane}}) = permutedims(hcat([normal_vector(be) for be in b]...))
_matrix_from_property(b::SubObjectIterator{<:Union{LinearHalfspace, LinearHyperplane}}) = permutedims(hcat([normal_vector(be) for be in b]...))

_matrix_from_property(b::SubObjectIterator{<:Union{AffineHalfspace, AffineHyperplane}}) = permutedims(hcat([vcat(-negbias(be), normal_vector(be)) for be in b]...))
_matrix_from_property(b::SubObjectIterator{<:Union{AffineHalfspace, AffineHyperplane}}) = permutedims(hcat([vcat(-negbias(be), normal_vector(be)) for be in b]...))

# only used for cones that are linear halfspaces
_matrix_from_property(b::SubObjectIterator{Cone{T}}) where T = _matrix_from_property(SubObjectIterator{LinearHalfspace{T}}(b.Obj, b.Acc, b.n))
# only used for cones that are linear halfspaces
_matrix_from_property(b::SubObjectIterator{Cone{T}}) where T = _matrix_from_property(SubObjectIterator{LinearHalfspace{T}}(b.Obj, b.Acc, b.n))

_matrix_from_property(b::SubObjectIterator) = permutedims(hcat(b...))
_matrix_from_property(b::SubObjectIterator) = permutedims(hcat(b...))

_oscar_matrix_from_property(a, b::SubObjectIterator) = matrix(a, _matrix_from_property(b))
_oscar_matrix_from_property(a, b::SubObjectIterator) = matrix(a, _matrix_from_property(b))

function _polymake_matrix_from_property(b::SubObjectIterator)
m = _matrix_from_property(b)
return Polymake.Matrix{Oscar._scalar_type_to_polymake(eltype(m))}(m)
function _polymake_matrix_from_property(b::SubObjectIterator)
m = _matrix_from_property(b)
return Polymake.Matrix{Oscar._scalar_type_to_polymake(eltype(m))}(m)
end
end

0 comments on commit aa8d4b6

Please sign in to comment.