From 5acd5c5867e63cd4ca5de5b5f39a7195028b2cdd Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Tue, 12 Mar 2024 15:51:03 +0100 Subject: [PATCH] Serialization: fix save/load of Int matrices/vectors in polymake numberfield objects (#3508) * Serialization: fix save/load of Int matrices/vectors in polymake numberfield objects * Update test/Serialization/PolyhedralGeometry.jl * fix for macos --- src/Serialization/polymake.jl | 2 ++ test/Serialization/PolyhedralGeometry.jl | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Serialization/polymake.jl b/src/Serialization/polymake.jl index 545074066253..eb9be9d34aa9 100644 --- a/src/Serialization/polymake.jl +++ b/src/Serialization/polymake.jl @@ -82,12 +82,14 @@ _pmdata_for_oscar(im::IncidenceMatrix, coeff::Field) = im _pmdata_for_oscar(g::Polymake.Graph{T}, coeff::Field) where T = Graph{T}(g) _pmdata_for_oscar(m::Polymake.Matrix, coeff::Field) = matrix(coeff, m) +_pmdata_for_oscar(m::Polymake.Matrix{Polymake.to_cxx_type(Int)}, coeff::Field) = Matrix{Int}(m) _pmdata_for_oscar(m::Polymake.Matrix{<:Polymake.Integer}, coeff::Field) = matrix(ZZ, m) _pmdata_for_oscar(m::Polymake.Matrix{<:Polymake.Rational}, coeff::Field) = matrix(QQ, m) _pmdata_for_oscar(m::Polymake.SparseMatrix, coeff::Field) = _pmdata_for_oscar(Polymake.common.dense(m), coeff) _pmdata_for_oscar(v::Polymake.Vector, coeff::Field) = collect(elem_type(coeff), map(coeff, v)) +_pmdata_for_oscar(v::Polymake.Vector{Polymake.to_cxx_type(Int)}, coeff::Field) = Vector{Int}(v) _pmdata_for_oscar(v::Polymake.Vector{<:Polymake.Integer}, coeff::Field) = collect(ZZRingElem, map(ZZ, v)) _pmdata_for_oscar(v::Polymake.Vector{<:Polymake.Rational}, coeff::Field) = collect(QQFieldElem, map(QQ, v)) diff --git a/test/Serialization/PolyhedralGeometry.jl b/test/Serialization/PolyhedralGeometry.jl index 2b80ea0de0e6..98296490769d 100644 --- a/test/Serialization/PolyhedralGeometry.jl +++ b/test/Serialization/PolyhedralGeometry.jl @@ -80,6 +80,8 @@ using Oscar: _integer_variables end nfdodecahedron = normal_fan(dodecahedron()) + # add some extra properties to check save / load + Polymake.give(Oscar.pm_object(nfdodecahedron), :MAXIMAL_CONES_FACETS) test_save_load_roundtrip(path, nfdodecahedron) do loaded @test n_rays(nfdodecahedron) == n_rays(loaded) @test number_of_maximal_cones(nfdodecahedron) == number_of_maximal_cones(loaded)