Skip to content

Commit

Permalink
even more conversion fixes for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz committed Jul 19, 2024
1 parent 0e0910c commit 69b4030
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ to_cxx_type(::Type{<:Tuple{A,B}}) where {A,B} =
StdPair{to_cxx_type(A), to_cxx_type(B)}
to_cxx_type(::Type{<:Pair{A,B}}) where {A,B} =
StdPair{to_cxx_type(A), to_cxx_type(B)}
to_cxx_type(::Type{<:StdPair{A,B}}) where {A,B} =
StdPair{to_cxx_type(A), to_cxx_type(B)}

to_jl_type(::Type{T}) where T = T
to_jl_type(::Type{CxxWrap.CxxBool}) = Bool
Expand All @@ -87,6 +89,7 @@ convert_to_pm_type(::Type{T}) where T <: TropicalNumber = T

convert_to_pm_type(::Nothing) = Nothing
convert_to_pm_type(::Type{Int32}) = Int64
convert_to_pm_type(::Type{CxxWrap.CxxLong}) = CxxWrap.CxxLong
convert_to_pm_type(::Type{<:AbstractFloat}) = Float64
convert_to_pm_type(::Type{<:AbstractString}) = String
convert_to_pm_type(::Type{<:Union{Base.Integer, Integer}}) = Integer
Expand Down Expand Up @@ -123,11 +126,12 @@ convert_to_pm_type(::Type{<:TropicalNumber{S,T}}) where S<:Union{Max,Min} where
# convert_to_pm_type(::Type{<:Union{AbstractSet, Set}}) = Set

# specific converts for container types we wrap:
convert_to_pm_type(::Type{<:Set{<:Base.Integer}}) = Set{Int64}
convert_to_pm_type(::Type{<:Base.AbstractSet{<:Base.Integer}}) = Set{Int64}
#convert_to_pm_type(::Type{<:Set{<:Base.Integer}}) = Set{Int64}
#convert_to_pm_type(::Type{<:Base.AbstractSet{<:Base.Integer}}) = Set{Int64}

for (pmT, jlT) in [(Integer, Base.Integer),
(Int64, Union{Int32,Int64,CxxWrap.CxxLong}),
(Int64, Union{Int32,Int64}),
(CxxWrap.CxxLong, CxxWrap.CxxLong),
(Rational, Union{Base.Rational, Rational}),
(TropicalNumber{Max, Rational}, TropicalNumber{Max, Rational}),
(TropicalNumber{Min, Rational}, TropicalNumber{Min, Rational}),
Expand All @@ -136,6 +140,7 @@ for (pmT, jlT) in [(Integer, Base.Integer),
@eval begin
convert_to_pm_type(::Type{<:AbstractMatrix{T}}) where T<:$jlT = Matrix{convert_to_pm_type($pmT)}
convert_to_pm_type(::Type{<:AbstractVector{T}}) where T<:$jlT = Vector{convert_to_pm_type($pmT)}
convert_to_pm_type(::Type{<:AbstractSet{T}}) where T<:$jlT = Set{convert_to_pm_type($pmT)}
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@
@test pma isa Polymake.Array
@test eltype(pma) <: Polymake.StdPair
@test first(first(pma)) isa Polymake.Set{Polymake.PmInt64}
@test last(first(pma)) isa Polymake.PmInt64
@test last(first(pma)) isa Union{Int64,Polymake.PmInt64}
end
end
2 changes: 1 addition & 1 deletion test/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@test Polymake.convert_to_pm_type(Base.Vector{String}) == Polymake.Array{String}

@test Polymake.convert_to_pm_type(Base.Vector{Base.Set{Int64}}) == Polymake.Array{Polymake.Set{Int64}}
@test Polymake.convert_to_pm_type(Base.Vector{Base.Set{Polymake.Integer}}) == Polymake.Array{Polymake.Set{Int64}}
@test Polymake.convert_to_pm_type(Base.Vector{Base.Set{Polymake.Integer}}) == Polymake.Array{Polymake.Set{Polymake.Integer}}
@test Polymake.convert_to_pm_type(Base.Vector{Base.Set{Int64}}) == Polymake.Array{Polymake.Set{Int64}}

@test Polymake.convert_to_pm_type(Base.Vector{Base.Vector{Int64}}) == Polymake.Array{Polymake.Array{Int64}}
Expand Down

0 comments on commit 69b4030

Please sign in to comment.