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 cd0e3f35..b36e2410 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 @@ -21,22 +26,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 @@ -56,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";' @@ -73,40 +75,47 @@ 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: 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' + - '1.6' - 'nightly' - os: ['macOS-latest'] + os: ['macos-latest'] + include: + - os: 'macos-14' + julia-version: '1.10' 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 }} diff --git a/OscarCI.toml b/OscarCI.toml index f6a159e9..98c93045 100644 --- a/OscarCI.toml +++ b/OscarCI.toml @@ -1,8 +1,8 @@ title = "metadata for oscar CI run" [env] -os = [ "ubuntu-latest", "macos-latest" ] -julia-version = [ "~1.6.0-0", "~1.9.0-0"] +os = [ "ubuntu-latest" ] +julia-version = [ "~1.6.0-0", "~1.10.0-0"] # branches = [ "release", "" ] [pkgs] @@ -20,8 +20,14 @@ julia-version = [ "~1.6.0-0", "~1.9.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" 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" 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; 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/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 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 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