From 78925354dc2a4d5278d4e3271aec693245ac4652 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Wed, 23 Aug 2023 23:28:34 +0200 Subject: [PATCH 1/3] bump version for polymake_oscarnumber --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 8447b65a..2f50a8dd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Polymake" uuid = "d720cf60-89b5-51f5-aff5-213f193123e7" repo = "https://github.com/oscar-system/Polymake.jl.git" -version = "0.11.3" +version = "0.11.4" [deps] BinaryWrappers = "f01c122e-0ea1-4f85-ad8f-907073ad7a9f" @@ -35,4 +35,4 @@ julia = "^1.6" lib4ti2_jll = "^1.6.10" libpolymake_julia_jll = "~0.10.3" polymake_jll = "^400.900.0" -polymake_oscarnumber_jll = "~0.2.2" +polymake_oscarnumber_jll = "~0.2.5" From c0dd91f565a975cc9363cd818d4eaab36e751fb7 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Wed, 23 Aug 2023 23:29:11 +0200 Subject: [PATCH 2/3] oscarnumber: disable callbacks during global destruction --- src/Polymake.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Polymake.jl b/src/Polymake.jl index 74b78a03..0670fd0c 100644 --- a/src/Polymake.jl +++ b/src/Polymake.jl @@ -281,7 +281,12 @@ function __init__() if isdefined(Main, :IJulia) && Main.IJulia.inited prepare_jupyter_kernel_for_visualization() end - + # this will disable callbacks for oscarnumber gc free calls + # to avoid some crashes during exit + # the data will be cleaned anyway once the iddict is cleared + Base.atexit() do + Polymake.oscarnumber_prepare_cleanup() + end end include("setup_apps.jl") From 16cb69d45210f4065ff1cab50e63643f486810e1 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Thu, 24 Aug 2023 09:46:14 +0200 Subject: [PATCH 3/3] add bigobject eltype function --- src/perlobj.jl | 6 ++++++ src/polymake/julia.rules | 10 ++++++++++ test/perlobj.jl | 7 ++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/perlobj.jl b/src/perlobj.jl index fb430e20..8be67a83 100644 --- a/src/perlobj.jl +++ b/src/perlobj.jl @@ -19,6 +19,12 @@ function bigobject(fname::String, name::String; kwargsdata...) return obj end +function bigobject_eltype(obj::BigObject) + res = call_function(:User, :get_bigobject_elemtype, obj) + res isa CxxWrap.StdString && !isempty(res) || error("could not determine element type of BigObject") + return String(res) +end + # polymake can either just give a reference or do a full copy. # but even that full copy will contain references to the same data # objects in memory, but this is fine since most of them are immutable anyway. diff --git a/src/polymake/julia.rules b/src/polymake/julia.rules index 14662104..b3d83f68 100644 --- a/src/polymake/julia.rules +++ b/src/polymake/julia.rules @@ -99,3 +99,13 @@ function set_shell_scalar($,$) { no strict 'refs'; ${"Polymake::User::$varname"} = $obj; } + +sub get_bigobject_elemtype($) { + my $params = $_[0]->type->params; + return "" unless defined($params) && @$params > 0; + if ($params->[0]->name =~ /^Min|Max$/) { + return $params->[1]->name; + } else { + return $params->[0]->name; + } +} diff --git a/test/perlobj.jl b/test/perlobj.jl index 5bbd17f6..9d72b145 100644 --- a/test/perlobj.jl +++ b/test/perlobj.jl @@ -95,7 +95,9 @@ @test (@pm tropical.Polytope{Max}(POINTS=points_int)) isa Polymake.BigObject - @test (@pm tropical.Polytope{Max}(POINTS=points_int)) isa Polymake.BigObject + tp = @pm tropical.Polytope{Max}(POINTS=points_int) + @test Polymake.bigobject_eltype(tp) == "Rational" + @test (@pm tropical.Polytope{Max, Rational}(POINTS=points_int)) isa Polymake.BigObject @test (@pm tropical.Polytope{Max, QuadraticExtension}(POINTS=points_int)) isa Polymake.BigObject @@ -108,10 +110,12 @@ @test P.VERTICES isa Polymake.Matrix{Float64} P = @pm polytope.Polytope{Float}(POINTS=[1 0.5 0; 1 0 1]) @test P.VERTICES isa Polymake.Matrix{Float64} + @test Polymake.bigobject_eltype(P) == "Float" P = @pm polytope.Polytope(POINTS=[1 0.5 0; 1 0 1]) @test P.VERTICES isa Polymake.Matrix{Polymake.Rational} P = @pm polytope.Polytope{Rational}(POINTS=[1 0.5 0; 1 0 1]) @test P.VERTICES isa Polymake.Matrix{Polymake.Rational} + @test Polymake.bigobject_eltype(P) == "Rational" end @testset verbose=true "PolymakeException" begin @@ -141,6 +145,7 @@ i = Polymake.polytope.icosahedron() @test i.VERTICES[1, :] == [1, 0, Polymake.QuadraticExtension{Polymake.Rational}(1//4, 1//4, 5), 1//2] @test i.VOLUME == Polymake.QuadraticExtension{Polymake.Rational}(5//4, 5//12, 5) + @test Polymake.bigobject_eltype(i) == "QuadraticExtension" end @testset verbose=true "attachments" begin