diff --git a/src/PolyhedralGeometry/helpers.jl b/src/PolyhedralGeometry/helpers.jl index dedeebea8ba..45d876183d9 100644 --- a/src/PolyhedralGeometry/helpers.jl +++ b/src/PolyhedralGeometry/helpers.jl @@ -611,6 +611,10 @@ function _parent_or_coefficient_field(::Type{T}, x, y...) where {T<:scalar_types missing end +function _parent_or_coefficient_field(::Type{T}, c::Tuple) where {T<:FieldElem} + return _parent_or_coefficient_field(T, c...) +end + function _determine_parent_and_scalar(f::Union{Field,ZZRing}, x...) _check_field_polyhedral(elem_type(f)) return (f, elem_type(f)) diff --git a/test/PolyhedralGeometry/scalar_types.jl b/test/PolyhedralGeometry/scalar_types.jl index 450e0ccc628..676e2645a7a 100644 --- a/test/PolyhedralGeometry/scalar_types.jl +++ b/test/PolyhedralGeometry/scalar_types.jl @@ -96,6 +96,11 @@ ) @test number_field(coefficient_field(j)) == number_field(coefficient_field(jj)) end + let ng = n_gon(5) + (A,b) = halfspace_matrix_pair(facets(ng)) + @test typeof(polyhedron(A,b)) == typeof(ng) + @test coefficient_field(polyhedron(A,b)) == coefficient_field((ng)) + end end @testset "Cross scalar operations" begin diff --git a/test/PolyhedralGeometry/setup_tests.jl b/test/PolyhedralGeometry/setup_tests.jl index c6cc8613922..af8e73b5f2e 100644 --- a/test/PolyhedralGeometry/setup_tests.jl +++ b/test/PolyhedralGeometry/setup_tests.jl @@ -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