Skip to content

Commit

Permalink
Merge pull request #469 from oscar-system/bl/undef
Browse files Browse the repository at this point in the history
allow passing nothing for undef values, update github actions
  • Loading branch information
benlorenz authored Feb 12, 2024
2 parents 065f8b6 + b138098 commit 310bf65
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 54 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/Invalidations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/createdocumentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/oscar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
45 changes: 27 additions & 18 deletions .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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";'
Expand All @@ -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 }}
16 changes: 11 additions & 5 deletions OscarCI.toml
Original file line number Diff line number Diff line change
@@ -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", "<matching>" ]

[pkgs]
Expand All @@ -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 = "<matching>"
Polymake = ""
julia-version = "~1.10.0-0"
os = "ubuntu-latest"
julia-version = "1.6"
os = "macos-latest"

[include.macaarch64]
Oscar = "<matching>"
Polymake = ""
julia-version = "1.10"
os = "macos-14"
2 changes: 1 addition & 1 deletion 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.11.12"
version = "0.11.13"

[deps]
BinaryWrappers = "f01c122e-0ea1-4f85-ad8f-907073ad7a9f"
Expand Down
3 changes: 2 additions & 1 deletion src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##################
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/polymake/julia.rules
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions test/matrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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<pm::QuadraticExtension<pm::Rational> >\n5/3 2 3\n10/3 5 6\n"
type = "pm::Matrix<pm::QuadraticExtension<pm::Rational>>"
mat = "5/3 2 3\n10/3 5 6\n"
@test string(V) in typename_variants("$type\n$mat")
end
end

Expand Down Expand Up @@ -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<pm::Polynomial<pm::Rational, long> >\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<pm::Polynomial<pm::Rational, long>>"
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
Expand Down
14 changes: 9 additions & 5 deletions test/oscarnumber.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/perlobj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 7 additions & 11 deletions test/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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<pm::Rational> "), (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<pm::Rational>"), (Polymake.OscarNumber, "common::OscarNumber")]
@testset verbose=true "Polymake.SparseVector{$E}" begin
V = Polymake.SparseVector{E}(jl_v)

Expand All @@ -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)
Expand All @@ -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

Expand Down
8 changes: 6 additions & 2 deletions test/vectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ using Polymake.CxxWrap
end
V[2] = T(10)//T(3)
@test V[2] == 10//3
@test string(V) == "pm::Vector<pm::QuadraticExtension<pm::Rational> >\n5/3 10/3 3"
type = "pm::Vector<pm::QuadraticExtension<pm::Rational>>"
vec = "5/3 10/3 3"
@test string(V) in typename_variants("$type\n$vec")
end
end

Expand Down Expand Up @@ -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<pm::Polynomial<pm::Rational, long> >\n2*x_0^2*x_1^3 + 3*x_1^2*x_2^3 0 4*x_0 + 5*x_2"
type = "pm::Vector<pm::Polynomial<pm::Rational, long>>"
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
Expand Down

2 comments on commit 310bf65

@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/100742

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.11.13 -m "<description of version>" 310bf65c1d91bda73893a21ef6d41556600bb47b
git push origin v0.11.13

Please sign in to comment.