Skip to content

Commit

Permalink
Serialization: fix save/load of Int matrices/vectors in polymake numb…
Browse files Browse the repository at this point in the history
…erfield objects (#3508)

* Serialization: fix save/load of Int matrices/vectors in polymake numberfield objects

* Update test/Serialization/PolyhedralGeometry.jl

* fix for macos
  • Loading branch information
benlorenz committed Mar 12, 2024
1 parent 653fded commit 5acd5c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Serialization/polymake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 2 additions & 0 deletions test/Serialization/PolyhedralGeometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5acd5c5

Please sign in to comment.