Skip to content

Commit

Permalink
serialization: fix load distinction between different fields, fix loa…
Browse files Browse the repository at this point in the history
…ding float polytopes
  • Loading branch information
benlorenz committed Feb 22, 2024
1 parent 14c88e9 commit 945ea75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/Serialization/PolyhedralGeometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ end

function load_object(s::DeserializerState, T::Type{<:PolyhedralObject},
field::U) where {U <: Union{QQField, AbstractAlgebra.Floats}}
if U isa QQField
load_from_polymake(T, Dict{Symbol, Any}(s.obj))
end
return load_from_polymake(T{QQFieldElem}, Dict{Symbol, Any}(s.obj))
return load_from_polymake(T{elem_type(field)}, Dict{Symbol, Any}(s.obj))
end

function load_object(s::DeserializerState, T::Type{<:PolyhedralObject{S}},
field::U) where {S <: FieldElem, U <: Union{QQField, AbstractAlgebra.Floats}}
field::U) where {S <: Union{QQFieldElem, Float64}, U <: Union{QQField, AbstractAlgebra.Floats}}
return load_from_polymake(T, Dict{Symbol, Any}(s.obj))
end

Expand Down
9 changes: 7 additions & 2 deletions src/Serialization/polymake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ const polymake2OscarTypes = Dict{String, Type}([
function load_from_polymake(::Type{T}, jsondict::Dict{Symbol, Any}) where {
T<:Union{Cone{<:scalar_types}, Polyhedron{<:scalar_types}, PolyhedralFan{<:scalar_types},
PolyhedralComplex{<:scalar_types}, SubdivisionOfPoints{<:scalar_types}, SimplicialComplex}}

inner_object = Polymake.call_function(:common, :deserialize_json_string, json(jsondict))
return T(inner_object)
if T <: PolyhedralObject{QQFieldElem}
return T(inner_object)
elseif T <: PolyhedralObject{Float64}
return T(inner_object, AbstractAlgebra.Floats{Float64}())
else
error("Unsupported object type $T for loading polymake object")
end
end


Expand Down

0 comments on commit 945ea75

Please sign in to comment.