diff --git a/Project.toml b/Project.toml index 9cc6c795..c6f04394 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.10" +version = "0.11.11" [deps] BinaryWrappers = "f01c122e-0ea1-4f85-ad8f-907073ad7a9f" diff --git a/src/Polymake.jl b/src/Polymake.jl index ce7fde64..986ba4a7 100644 --- a/src/Polymake.jl +++ b/src/Polymake.jl @@ -165,9 +165,9 @@ include(type_translator) _pm_rand_helper() = rand(Int64) -function set_rand_source(f::Function) - cf = CxxWrap.@safe_cfunction($f, Int64, ()) - set_rand_source(cf) +function set_rand_source() + _default_rand_helper = CxxWrap.@safe_cfunction(_pm_rand_helper, Int64, ()) + set_rand_source(_default_rand_helper) end function __init__() @@ -273,7 +273,7 @@ function __init__() application("common") end - set_rand_source(_pm_rand_helper) + set_rand_source() # We need to set the Julia types as c types for polymake for (name, c_type) in C_TYPES diff --git a/test/util.jl b/test/util.jl index 28b412e8..1dd504e2 100644 --- a/test/util.jl +++ b/test/util.jl @@ -1,3 +1,5 @@ +_test_rand_fun() = return 42 + @testset verbose=true "utilities" begin facets = [ 0 1 0 ; 0 0 1 ; 1 -1 0 ; 1 0 -1 ] @@ -85,9 +87,12 @@ @test Polymake.shell_execute(raw"""$c->apply_rule("_4ti2.integer_points");""") isa NamedTuple @test Polymake.exists(c, "LATTICE_POINTS_GENERATORS") || Polymake.exists(c, "HILBERT_BASIS_GENERATORS") end + + @testset verbose=true "seeding" begin try - Polymake.set_rand_source(() -> return 42) + _test_rand_cfun = Polymake.CxxWrap.@safe_cfunction(_test_rand_fun, Int64, ()) + Polymake.set_rand_source(_test_rand_cfun) v1 = Polymake.polytope.rand_sphere(3,10).VERTICES v2 = Polymake.polytope.rand_sphere(3,10).VERTICES vs1 = Polymake.polytope.rand_sphere(3,10; seed=42).VERTICES @@ -99,7 +104,7 @@ vr = Polymake.polytope.rand_sphere(3,10).VERTICES @test v1 != vr finally - Polymake.set_rand_source(Polymake._pm_rand_helper) + Polymake.set_rand_source() end end end