Skip to content

Commit

Permalink
Merge pull request #444 from oscar-system/lk/vector_tropical_number
Browse files Browse the repository at this point in the history
  • Loading branch information
benlorenz authored Jun 24, 2023
2 parents a6c8c32 + acf388e commit eea9571
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Polymake"
uuid = "d720cf60-89b5-51f5-aff5-213f193123e7"
repo = "https://github.com/oscar-system/Polymake.jl.git"
version = "0.9.2"
version = "0.10.0"

[deps]
BinaryWrappers = "f01c122e-0ea1-4f85-ad8f-907073ad7a9f"
Expand Down Expand Up @@ -32,5 +32,5 @@ Scratch = "^1.1"
TOPCOM_jll = "~0.17.8"
julia = "^1.6"
lib4ti2_jll = "^1.6.10"
libpolymake_julia_jll = "~0.9.0"
libpolymake_julia_jll = "~0.10.0"
polymake_jll = "^400.900.0"
6 changes: 3 additions & 3 deletions src/Polymake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import TOPCOM_jll
using libpolymake_julia_jll


const jlpolymake_version_range = (v"0.9.0", v"0.10")
const jlpolymake_version_range = (v"0.10.0", v"0.11")

struct PolymakeError <: Exception
msg
Expand Down Expand Up @@ -81,7 +81,7 @@ include("ijulia.jl")

@wrapmodule(joinpath(libpolymake_julia), :define_module_polymake)

include(polymake_jll.generate_deps_tree)
include(libpolymake_julia_jll.generate_deps_tree)

include(type_translator)

Expand All @@ -93,7 +93,7 @@ function __init__()
@generate_wrappers(Ninja_jll),
@generate_wrappers(Perl_jll),
]
polymake_deps_tree = @get_scratch!("$(scratch_key)_depstree")
polymake_deps_tree = @get_scratch!("$(scratch_key)_depstree_v2")

# we run this on every init to make sure all artifacts still exist
prepare_deps_tree(polymake_deps_tree)
Expand Down
5 changes: 4 additions & 1 deletion src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ NodeMap{Dir, T}(g::Graph{Dir}) where Dir<:DirType where T<:Set{<:Union{Int64, Cx

convert_to_pm_type(::Type{HomologyGroup{T}}) where T<:Integer = HomologyGroup{T}
convert_to_pm_type(::Type{<:QuadraticExtension{T}}) where T<:Rational = QuadraticExtension{Rational}
convert_to_pm_type(::Type{<:TropicalNumber{S,T}}) where S<:Union{Max,Min} where T<:Rational = TropicalNumber{S,Rational}
# convert_to_pm_type(::Type{<:Union{AbstractSet, Set}}) = Set

# specific converts for container types we wrap:
Expand All @@ -106,7 +107,9 @@ convert_to_pm_type(::Type{<:Base.AbstractSet{<:Base.Integer}}) = Set{Int64}
for (pmT, jlT) in [(Integer, Base.Integer),
(Int64, Union{Int32,Int64,CxxWrap.CxxLong}),
(Rational, Union{Base.Rational, Rational}),
(QuadraticExtension{Polymake.Rational}, QuadraticExtension{Polymake.Rational})]
(TropicalNumber{Max, Rational}, TropicalNumber{Max, Rational}),
(TropicalNumber{Min, Rational}, TropicalNumber{Min, Rational}),
(QuadraticExtension{Rational}, QuadraticExtension{Rational})]
@eval begin
convert_to_pm_type(::Type{<:AbstractMatrix{T}}) where T<:$jlT = Matrix{to_cxx_type($pmT)}
convert_to_pm_type(::Type{<:AbstractVector{T}}) where T<:$jlT = Vector{to_cxx_type($pmT)}
Expand Down
8 changes: 0 additions & 8 deletions src/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ end

Base.allunique(::Set) = true

# delete! : Defined on the C++ side
Base.delete!(s::Set{T}, x) where T = delete!(s, T(x))
# empty! : Defined on the C++ side
Base.empty(s::Set{T}, ::Type{U}=T) where {T, U} = Set{to_cxx_type(U)}()
#
Expand All @@ -90,10 +88,6 @@ function Base.filter!(pred, s::Set{T}) where T
return s
end

# in : Defined on the C++ side
Base.in(x::Base.Integer, s::Set{T}) where T = in(T(x), s)

#
# # isempty : Defined on the C++

function Base.iterate(S::Set)
Expand Down Expand Up @@ -125,8 +119,6 @@ function Base.pop!(s::Set{T}) where T
return pop!(s, first(s))
end

# push! : Defined on the C++ side
Base.push!(s::Set{T}, x::Base.Integer) where T = push!(s, T(x))
# show : Defined on the C++ side

Base.sizehint!(s::Set, newsz) = s
Expand Down
2 changes: 1 addition & 1 deletion src/setup_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const SmallObject = Union{
EdgeMap,
NodeMap,
}
const VecOrMat_eltypes = Union{Int64, Integer, Rational, Float64, QuadraticExtension{Rational}, CxxWrap.CxxLong, Polynomial{Rational, CxxWrap.CxxLong}}
const VecOrMat_eltypes = Union{Int64, Integer, Rational, Float64, QuadraticExtension{Rational}, CxxWrap.CxxLong, Polynomial{Rational, CxxWrap.CxxLong}, TropicalNumber{Polymake.Max, Polymake.Rational}, TropicalNumber{Polymake.Min, Polymake.Rational}}

const TypeConversionFunctions = Dict(
Symbol("Int") => to_int,
Expand Down
6 changes: 3 additions & 3 deletions test/arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@
@test A == Polymake.Array{T}(2l+2, elt)
end

@testset "Polymake.Array{Polymake.Array{Polymake.Set{Int64}}}" begin
@testset "Polymake.Array{Polymake.Set{Polymake.Set{Int64}}}" begin
c = Polymake.polytope.cube(2, 1, 0)
PC = Polymake.polytope.PointConfiguration(POINTS=c.VERTICES)
all = Polymake.polytope.topcom_all_triangulations(PC)
@test all isa Polymake.Array{Polymake.Array{Polymake.Set{Polymake.to_cxx_type(Int64)}}}
@test all isa Polymake.Array{Polymake.Set{Polymake.Set{Polymake.to_cxx_type(Int64)}}}
@test length(all) == 2
@test size(all) == (2,)
for triang in all
@test triang isa Polymake.Array{Polymake.Set{Polymake.to_cxx_type(Int64)}}
@test triang isa Polymake.Set{Polymake.Set{Polymake.to_cxx_type(Int64)}}
end
end

Expand Down
29 changes: 29 additions & 0 deletions test/tropicalnumber.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,33 @@
end
end
end

@testset "Containers" begin
for VType in [Polymake.Vector, Polymake.Array]
for A in AdditionTypes
v = VType{Polymake.TropicalNumber{A, Polymake.Rational}}(5)
@test v isa VType{Polymake.TropicalNumber{A, Polymake.Rational}}
# If this at some point might work, we want to get notified:
@test_broken v isa VType{Polymake.TropicalNumber{A}}
@test length(v) == 5
@test v+v == v
for e in v
@test iszero(e)
end
end
end
for MType in [Polymake.Matrix, Polymake.SparseMatrix]
for A in AdditionTypes
v = MType{Polymake.TropicalNumber{A, Polymake.Rational}}(5,5)
@test v isa MType{Polymake.TropicalNumber{A, Polymake.Rational}}
# If this at some point might work, we want to get notified:
@test_broken v isa MType{Polymake.TropicalNumber{A}}
@test size(v) == (5,5)
@test v+v == v
for e in v
@test iszero(e)
end
end
end
end
end

2 comments on commit eea9571

@benlorenz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/86222

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.0 -m "<description of version>" eea957180f6b85931018a8a004b07c4ba756395f
git push origin v0.10.0

Please sign in to comment.