From 8c9ee049d2bb261fd288a68fc4e7640f50654878 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Fri, 9 Feb 2024 10:48:10 +0100 Subject: [PATCH 1/9] allow passing nothing for undef values --- src/convert.jl | 3 ++- src/polymake/julia.rules | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/convert.jl b/src/convert.jl index 04e9b039..eb13b1e8 100644 --- a/src/convert.jl +++ b/src/convert.jl @@ -28,6 +28,7 @@ struct PolymakeType end convert(::Type{PolymakeType}, x::T) where T = convert(convert_to_pm_type(T), x) convert(::Type{PolymakeType}, v::Visual) = v.obj +convert(::Type{PolymakeType}, ::Nothing) = call_function(PropertyValue, :common, :get_undef) convert(::Type{OptionSet}, dict) = OptionSet(dict) ############### Adjusting type parameter to CxxWrap ################## @@ -69,7 +70,7 @@ convert_to_pm_type(T::Type) = throw(ArgumentError("Unrecognized argument type: $ convert_to_pm_type(::Type{T}) where T <: Union{Int64, Float64} = T convert_to_pm_type(::Type{T}) where T <: Union{BigObject, PropertyValue, OptionSet, TropicalNumber} = T - +convert_to_pm_type(::Nothing) = Nothing convert_to_pm_type(::Type{Int32}) = Int64 convert_to_pm_type(::Type{<:AbstractFloat}) = Float64 convert_to_pm_type(::Type{<:AbstractString}) = String diff --git a/src/polymake/julia.rules b/src/polymake/julia.rules index b3d83f68..cccedeb8 100644 --- a/src/polymake/julia.rules +++ b/src/polymake/julia.rules @@ -51,6 +51,11 @@ function is_boolean_wrapper($) { return is_boolean($c); } +# helper function for converting `nothing` +function get_undef() { + return undef; +} + function jupyter_visual_threejs(Visual::Object+) { my $string = ""; local $ThreeJS::is_used_in_jupyter=1; From 85ae8d764b4056bed89ce8f969562208a346319d Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Fri, 9 Feb 2024 10:48:23 +0100 Subject: [PATCH 2/9] test nothing-undef mapping --- test/perlobj.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/perlobj.jl b/test/perlobj.jl index 1805fae8..b92ae3e1 100644 --- a/test/perlobj.jl +++ b/test/perlobj.jl @@ -152,6 +152,9 @@ @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" + + undefobj = Polymake.polytope.Polytope(POINTS=nothing) + @test undefobj.POINTS === nothing end @testset verbose=true "attachments" begin From 0ff1337408ca020d9c992e6d3c628671fab666f0 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Fri, 9 Feb 2024 10:48:37 +0100 Subject: [PATCH 3/9] prepare next version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 18548010..9dec021a 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.12" +version = "0.11.13" [deps] BinaryWrappers = "f01c122e-0ea1-4f85-ad8f-907073ad7a9f" From ea30c7b59cd185864f4bd7ab0eb5ed45d33b8934 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Fri, 9 Feb 2024 11:12:35 +0100 Subject: [PATCH 4/9] fix oscarnumber tests --- test/oscarnumber.jl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/oscarnumber.jl b/test/oscarnumber.jl index 84a089ba..311a395a 100644 --- a/test/oscarnumber.jl +++ b/test/oscarnumber.jl @@ -25,7 +25,9 @@ @test Polymake.OscarNumber(m) isa Polymake.OscarNumber if isdefined(@__MODULE__, :_with_oscar) && _with_oscar - @test Polymake.unwrap(M) isa Hecke.EmbeddedNumFieldElem{NfAbsNSElem} + if isdefined(Hecke, :EmbeddedNumFieldElem) + @test Polymake.unwrap(M) isa Hecke.EmbeddedNumFieldElem + end end @test Polymake.unwrap(M) == m @test M == Polymake.OscarNumber(m) @@ -113,10 +115,12 @@ @test M * A2 == A2 * M == Polymake.OscarNumber(a1*a2 + 15 + 7*a2) @test Polymake.OscarNumber(5) // A2 == Polymake.OscarNumber(a2^2) # avoid test error for older oscar versions - if length(methods(Polymake._fieldelem_to_float, (EmbeddedElem,), Oscar)) > 0 - @test Polymake.common.convert_to{Float64}(A2) isa Float64 - fa2 = Polymake.common.convert_to{Float64}(A2) - @test isapprox(fa2, 1.71; rtol=0.001) + if isdefined(Hecke, :EmbeddedNumFieldElem) + if length(methods(Polymake._fieldelem_to_float, (EmbeddedNumFieldElem,), Oscar)) > 0 + @test Polymake.common.convert_to{Float64}(A2) isa Float64 + fa2 = Polymake.common.convert_to{Float64}(A2) + @test isapprox(fa2, 1.71; rtol=0.001) + end end end end From f899b2b7adecbb08acac8a00ec6bebe38e7903c5 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Fri, 9 Feb 2024 13:11:57 +0100 Subject: [PATCH 5/9] CI: remove julia 1.9, add 1.10 as default for oscarci --- .github/workflows/runtests.yml | 14 +++----------- OscarCI.toml | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml index cd0e3f35..ee6c1302 100644 --- a/.github/workflows/runtests.yml +++ b/.github/workflows/runtests.yml @@ -21,22 +21,15 @@ jobs: # github services (for mongodb service) only works on linux test-with-mongodb: runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.julia-version == 'nightly' || matrix.julia-version == '~1.10.0-0' }} + continue-on-error: ${{ matrix.julia-version == 'nightly' }} strategy: matrix: julia-version: - '~1.6.0-0' - - '~1.8.0-0' - '~1.10.0-0' + - 'nightly' os: ['ubuntu-latest'] cxxwrap: [ '' ] - include: - - cxxwrap: '0.14' - os: ubuntu-latest - julia-version: 1.9 - - cxxwrap: '0.14' - os: ubuntu-latest - julia-version: nightly fail-fast: false # Service containers to run @@ -83,14 +76,13 @@ jobs: # this one is only for macos, ubuntu is run with mongodb in the other job test: runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.julia-version == 'nightly' || matrix.julia-version == '~1.10.0-0' }} + continue-on-error: ${{ matrix.julia-version == 'nightly' }} env: JULIA_PKG_SERVER: "" strategy: matrix: julia-version: - '~1.6.0-0' - - '~1.9.0-0' - '~1.10.0-0' - 'nightly' os: ['macOS-latest'] diff --git a/OscarCI.toml b/OscarCI.toml index f6a159e9..b126dc88 100644 --- a/OscarCI.toml +++ b/OscarCI.toml @@ -2,7 +2,7 @@ title = "metadata for oscar CI run" [env] os = [ "ubuntu-latest", "macos-latest" ] -julia-version = [ "~1.6.0-0", "~1.9.0-0"] +julia-version = [ "~1.6.0-0", "~1.10.0-0"] # branches = [ "release", "" ] [pkgs] From 1a368a73f88d3e68cdb89fd4e12d10717566c767 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Fri, 9 Feb 2024 13:18:23 +0100 Subject: [PATCH 6/9] CI: reorganize julia versions and os versions --- .github/workflows/runtests.yml | 6 ++++-- OscarCI.toml | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml index ee6c1302..31ee6a16 100644 --- a/.github/workflows/runtests.yml +++ b/.github/workflows/runtests.yml @@ -82,10 +82,12 @@ jobs: strategy: matrix: julia-version: - - '~1.6.0-0' - '~1.10.0-0' - 'nightly' - os: ['macOS-latest'] + os: ['macos-14'] + include: + - os: 'macos-latest' + julia-version: 1.6 fail-fast: false steps: diff --git a/OscarCI.toml b/OscarCI.toml index b126dc88..98c93045 100644 --- a/OscarCI.toml +++ b/OscarCI.toml @@ -1,7 +1,7 @@ title = "metadata for oscar CI run" [env] -os = [ "ubuntu-latest", "macos-latest" ] +os = [ "ubuntu-latest" ] julia-version = [ "~1.6.0-0", "~1.10.0-0"] # branches = [ "release", "" ] @@ -20,8 +20,14 @@ julia-version = [ "~1.6.0-0", "~1.10.0-0"] julia-version = "nightly" os = "ubuntu-latest" - [include.julia_1_10] + [include.macamd64] Oscar = "" Polymake = "" - julia-version = "~1.10.0-0" - os = "ubuntu-latest" + julia-version = "1.6" + os = "macos-latest" + + [include.macaarch64] + Oscar = "" + Polymake = "" + julia-version = "1.10" + os = "macos-14" From 4d1d8ce0c6ccbf1997633027a1b30b2a0aebf4b9 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Fri, 9 Feb 2024 13:35:34 +0100 Subject: [PATCH 7/9] CI: bump some actions, add cache,... --- .github/workflows/Invalidations.yml | 12 ++++++++---- .github/workflows/createdocumentation.yml | 11 ++++++++--- .github/workflows/oscar.yml | 4 ++-- .github/workflows/runtests.yml | 23 +++++++++++++++++++---- 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/.github/workflows/Invalidations.yml b/.github/workflows/Invalidations.yml index 4021410a..87426ae2 100644 --- a/.github/workflows/Invalidations.yml +++ b/.github/workflows/Invalidations.yml @@ -9,6 +9,11 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +# needed to allow julia-actions/cache to delete old caches that it has created +permissions: + actions: write + contents: read + jobs: compare-invalidations: # Only run on PRs to the default branch. @@ -19,15 +24,14 @@ jobs: - uses: julia-actions/setup-julia@v1 with: version: '1' - - uses: actions/checkout@v3 - - uses: julia-actions/julia-buildpkg@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/cache@v1 - uses: julia-actions/julia-invalidations@v1 id: invs_pr - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.repository.default_branch }} - - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-invalidations@v1 id: invs_default diff --git a/.github/workflows/createdocumentation.yml b/.github/workflows/createdocumentation.yml index 467ee1a4..93a73aad 100644 --- a/.github/workflows/createdocumentation.yml +++ b/.github/workflows/createdocumentation.yml @@ -8,6 +8,10 @@ on: pull_request: workflow_dispatch: +# needed to allow julia-actions/cache to delete old caches that it has created +permissions: + actions: write + concurrency: # group by workflow and ref; the last slightly strange component ensures that for pull # requests, we limit to 1 concurrent job, but for the master branch we don't @@ -20,16 +24,17 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Set up Julia" uses: julia-actions/setup-julia@v1 with: - version: '1.6' - - uses: julia-actions/julia-buildpkg@v1 + version: '1.10' + - uses: julia-actions/cache@v1 - name: "Add Documenter package" run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - name: "Build and deploy documentation" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key run: julia --project=docs/ docs/make.jl diff --git a/.github/workflows/oscar.yml b/.github/workflows/oscar.yml index ad292c62..77386185 100644 --- a/.github/workflows/oscar.yml +++ b/.github/workflows/oscar.yml @@ -23,7 +23,7 @@ jobs: JULIA_PKG_SERVER: "" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Set up Julia" uses: julia-actions/setup-julia@v1 with: @@ -64,7 +64,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Set up Julia" uses: julia-actions/setup-julia@v1 with: diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml index 31ee6a16..e347dcf8 100644 --- a/.github/workflows/runtests.yml +++ b/.github/workflows/runtests.yml @@ -10,6 +10,11 @@ on: - master workflow_dispatch: +# needed to allow julia-actions/cache to delete old caches that it has created +permissions: + actions: write + contents: read + concurrency: # group by workflow and ref; the last slightly strange component ensures that for pull # requests, we limit to 1 concurrent job, but for the master branch we don't @@ -49,11 +54,15 @@ jobs: JULIA_PKG_SERVER: "" POLYDB_TEST_URI: "mongodb://admin:admin@localhost:27017/?authSource=admin" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Set up Julia" uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.julia-version }} + - uses: julia-actions/cache@v1 + with: + cache-name: julia-cache;workflow=${{ github.workflow }};julia=${{ matrix.julia-version }};arch=${{ runner.arch }} + include-matrix: false - name: "pin CxxWrap" if: matrix.cxxwrap != '' run: julia --project -e 'using Pkg; pkg"add CxxWrap@${{ matrix.cxxwrap }}"; pkg"pin CxxWrap";' @@ -66,12 +75,13 @@ jobs: mongorestore --host localhost -u admin -p admin --port 27017 .github/polydb_dump - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v2 + - uses: codecov/codecov-action@v4 with: file: ./lcov.info flags: unittests name: codecov-umbrella fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} # this one is only for macos, ubuntu is run with mongodb in the other job test: @@ -91,16 +101,21 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Set up Julia" uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.julia-version }} + - uses: julia-actions/cache@v1 + with: + cache-name: julia-cache;workflow=${{ github.workflow }};julia=${{ matrix.julia-version }};arch=${{ runner.arch }} + include-matrix: false - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v2 + - uses: codecov/codecov-action@v4 with: file: ./lcov.info flags: unittests name: codecov-umbrella fail_ci_if_error: false + token: ${{ secrets.CODECOV_TOKEN }} From 1b88962aaf603561967a8bfb4680d9a8f0d82e94 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Fri, 9 Feb 2024 19:19:45 +0100 Subject: [PATCH 8/9] tests: handle different type printing on new macos --- test/matrices.jl | 8 ++++++-- test/runtests.jl | 5 +++++ test/sparsevector.jl | 18 +++++++----------- test/vectors.jl | 8 ++++++-- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/test/matrices.jl b/test/matrices.jl index ae0f5e35..fbf5f102 100644 --- a/test/matrices.jl +++ b/test/matrices.jl @@ -199,7 +199,9 @@ using Polymake.CxxWrap @test V[2] = T(10)//T(3) isa typeof(T(10)//T(3)) V[2] = T(10)//T(3) @test V[2] == 10//3 - @test string(V) == "pm::Matrix >\n5/3 2 3\n10/3 5 6\n" + type = "pm::Matrix>" + mat = "5/3 2 3\n10/3 5 6\n" + @test string(V) in typename_variants("$type\n$mat") end end @@ -545,7 +547,9 @@ using Polymake.CxxWrap @test (V[2, 1] = T([4, 5], [1 0 0; 0 0 1])) isa T V[2, 1] = T([4, 5], [1 0 0; 0 0 1]) @test V[2, 1] == T([4, 5], [1 0 0; 0 0 1]) - @test string(V) == "pm::Matrix >\n2*x_0^2*x_1^3 + 3*x_1^2*x_2^3 0 0 0\n4*x_0 + 5*x_2 0 0 0\n0 0 0 x_0 + x_1 + x_2\n" + type = "pm::Matrix>" + mat = "2*x_0^2*x_1^3 + 3*x_1^2*x_2^3 0 0 0\n4*x_0 + 5*x_2 0 0 0\n0 0 0 x_0 + x_1 + x_2\n" + @test string(V) in typename_variants("$type\n$mat") end end end diff --git a/test/runtests.jl b/test/runtests.jl index a989d0ff..2bd6175c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -26,6 +26,11 @@ struct MyInt x::Int end # needed in test/convert.jl include("Aqua.jl") +function typename_variants(s::AbstractString) + r = replace(s, ">>" => "> >") + return [r, s] +end + include("integers.jl") include("rationals.jl") include("quadraticextension.jl") diff --git a/test/sparsevector.jl b/test/sparsevector.jl index ae300b2c..c571ff9b 100644 --- a/test/sparsevector.jl +++ b/test/sparsevector.jl @@ -112,7 +112,7 @@ using Polymake.SparseArrays end @testset verbose=true "Low-level operations" begin - for (E,s) in [(Int64, "long"), (Polymake.Integer, "pm::Integer"), (Polymake.Rational, "pm::Rational"), (Float64, "double"), (Polymake.QuadraticExtension{Polymake.Rational}, "pm::QuadraticExtension "), (Polymake.OscarNumber, "common::OscarNumber")] + for (E,s) in [(Int64, "long"), (Polymake.Integer, "pm::Integer"), (Polymake.Rational, "pm::Rational"), (Float64, "double"), (Polymake.QuadraticExtension{Polymake.Rational}, "pm::QuadraticExtension"), (Polymake.OscarNumber, "common::OscarNumber")] @testset verbose=true "Polymake.SparseVector{$E}" begin V = Polymake.SparseVector{E}(jl_v) @@ -124,6 +124,8 @@ using Polymake.SparseArrays @test length(V) == 3 @test size(V) == (3,) + type = "pm::SparseVector<$s>" + for T in [IntTypes; Polymake.Integer] V = Polymake.SparseVector{E}(jl_v) # local copy setindex!(V, T(5), 1) @@ -134,17 +136,11 @@ using Polymake.SparseArrays @test V[2] = T(10) isa T V[2] = T(10) @test V[2] == 10 - if E == Polymake.OscarNumber - @test string(V) == string("pm::SparseVector<", s, ">\n(5) (10) (3)") - else - @test string(V) == string("pm::SparseVector<", s, ">\n5 10 3") - end - end - if E == Polymake.OscarNumber - @test string(Polymake.SparseVector{E}(jl_s)) == string("pm::SparseVector<", s, ">\n(3) (1 (1))") - else - @test string(Polymake.SparseVector{E}(jl_s)) == string("pm::SparseVector<", s, ">\n(3) (1 1)") + vec = E != Polymake.OscarNumber ? "5 10 3" : "(5) (10) (3)" + @test string(V) in typename_variants("$type\n$vec") end + vec = E != Polymake.OscarNumber ? "(3) (1 1)" : "(3) (1 (1))" + @test string(Polymake.SparseVector{E}(jl_s)) in typename_variants("$type\n$vec") end end diff --git a/test/vectors.jl b/test/vectors.jl index 880e4dd0..04cad51e 100644 --- a/test/vectors.jl +++ b/test/vectors.jl @@ -213,7 +213,9 @@ using Polymake.CxxWrap end V[2] = T(10)//T(3) @test V[2] == 10//3 - @test string(V) == "pm::Vector >\n5/3 10/3 3" + type = "pm::Vector>" + vec = "5/3 10/3 3" + @test string(V) in typename_variants("$type\n$vec") end end @@ -494,7 +496,9 @@ using Polymake.CxxWrap @test (W[3] = T([4, 5], [1 0 0; 0 0 1])) isa Polymake.to_cxx_type(T) W[3] = T([4, 5], [1 0 0; 0 0 1]) @test W[3] == T([4, 5], [1 0 0; 0 0 1]) - @test string(W) == "pm::Vector >\n2*x_0^2*x_1^3 + 3*x_1^2*x_2^3 0 4*x_0 + 5*x_2" + type = "pm::Vector>" + polystr = "2*x_0^2*x_1^3 + 3*x_1^2*x_2^3 0 4*x_0 + 5*x_2" + @test string(W) in typename_variants("$type\n$polystr") end end end From b1380980c3d5a83f2799dab76d77f47047fe4c63 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Sun, 11 Feb 2024 09:41:52 +0100 Subject: [PATCH 9/9] CI: run nightly on macos-latest for now until setup-julia has a new release --- .github/workflows/runtests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/runtests.yml b/.github/workflows/runtests.yml index e347dcf8..b36e2410 100644 --- a/.github/workflows/runtests.yml +++ b/.github/workflows/runtests.yml @@ -92,12 +92,12 @@ jobs: strategy: matrix: julia-version: - - '~1.10.0-0' + - '1.6' - 'nightly' - os: ['macos-14'] + os: ['macos-latest'] include: - - os: 'macos-latest' - julia-version: 1.6 + - os: 'macos-14' + julia-version: '1.10' fail-fast: false steps: