From c9b376ad13ac1e548611ca27cdb28030573f6b54 Mon Sep 17 00:00:00 2001 From: Pedro Maciel Xavier Date: Tue, 24 Sep 2024 14:01:38 -0400 Subject: [PATCH 1/6] Bump Version --- Project.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 1dc9d9a..2d6ea0a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QUBOTools" uuid = "60eb5b62-0a39-4ddc-84c5-97d2adff9319" -authors = ["pedromxavier ", "pedroripper ", "AndradeTiago ", "joaquimg ", "bernalde "] -version = "0.9.3" +authors = ["pedromxavier ", "pedroripper ", "AndradeTiago ", "joaquimg ", "bernalde "] +version = "0.10.0" [deps] GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" @@ -17,6 +17,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" [weakdeps] MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" From 089a1782411c3f794f3c91254f2f52bf010668fc Mon Sep 17 00:00:00 2001 From: Pedro Maciel Xavier Date: Tue, 24 Sep 2024 14:02:16 -0400 Subject: [PATCH 2/6] Enhance constant definition --- src/QUBOTools.jl | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/QUBOTools.jl b/src/QUBOTools.jl index 27a1384..605601d 100644 --- a/src/QUBOTools.jl +++ b/src/QUBOTools.jl @@ -4,17 +4,50 @@ import Printf import HDF5 import JSON import JSONSchema +import NetworkLayout +import TOML + using Graphs using GeometryBasics using LinearAlgebra -import NetworkLayout using SparseArrays using Statistics using RecipesBase using Random + import PseudoBooleanOptimization as PBO import PseudoBooleanOptimization: varlt, varshow +const __PROJECT__ = Ref{Union{String,Nothing}}(nothing) + +function __project__() + if isnothing(__PROJECT__[]) + proj_path = abspath(dirname(@__DIR__)) + + @assert isdir(proj_path) + + __PROJECT__[] = proj_path + end + + return __PROJECT__[]::String +end + +const __VERSION__ = Ref{Union{VersionNumber,Nothing}}(nothing) + +function __version__()::VersionNumber + if isnothing(__VERSION__[]) + proj_file_path = abspath(__project__(), "Project.toml") + + @assert isfile(proj_file_path) + + proj_file_data = TOML.parsefile(proj_file_path) + + __VERSION__[] = VersionNumber(proj_file_data["version"]) + end + + return __VERSION__[]::VersionNumber +end + const ↓ = -1 # \downarrow[tab] const ↑ = +1 # \uparrow[tab] From 28ffd6298001decb123c6f571301ce4e87c14d8c Mon Sep 17 00:00:00 2001 From: Pedro Maciel Xavier Date: Tue, 24 Sep 2024 14:02:27 -0400 Subject: [PATCH 3/6] Fix function scope --- src/library/frame.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/frame.jl b/src/library/frame.jl index 4ebc01e..e35a2b7 100644 --- a/src/library/frame.jl +++ b/src/library/frame.jl @@ -22,7 +22,7 @@ function Base.Symbol(s::Sense) end end -String(s::Sense) = String(Symbol(s)) +Base.String(s::Sense) = String(Symbol(s)) domain(x::Domain) = x @@ -48,7 +48,7 @@ function Base.Symbol(x::Domain) end end -String(x::Domain) = String(Symbol(x)) +Base.String(x::Domain) = String(Symbol(x)) function sense(obj::Any) return sense(frame(obj)) From 62fe71e51f96b64ca19c9d70a097fba4fb5c5ec1 Mon Sep 17 00:00:00 2001 From: Pedro Maciel Xavier Date: Tue, 24 Sep 2024 14:03:07 -0400 Subject: [PATCH 4/6] Deprecate `generate` methods --- src/library/synthesis/abstract.jl | 4 ++++ src/library/synthesis/sherrington_kirkpatrick.jl | 2 ++ src/library/synthesis/wishart.jl | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/library/synthesis/abstract.jl b/src/library/synthesis/abstract.jl index 65f0581..24f97d7 100644 --- a/src/library/synthesis/abstract.jl +++ b/src/library/synthesis/abstract.jl @@ -1,3 +1,7 @@ function generate(problem::AbstractProblem) return generate(Random.GLOBAL_RNG, problem) end + +macro _deprecate_generate() + return quote @warn("Depraction Warning: To use `generate`, please refer to `QUBOLib.jl`") end +end diff --git a/src/library/synthesis/sherrington_kirkpatrick.jl b/src/library/synthesis/sherrington_kirkpatrick.jl index e36af4a..a2a5383 100644 --- a/src/library/synthesis/sherrington_kirkpatrick.jl +++ b/src/library/synthesis/sherrington_kirkpatrick.jl @@ -21,6 +21,8 @@ end const SK{T} = SherringtonKirkpatrick{T} function generate(rng, problem::SherringtonKirkpatrick{T}) where {T} + @_deprecate_generate() + f, x = PBO.sherrington_kirkpatrick( rng, PBO.PBF{Int,T}, diff --git a/src/library/synthesis/wishart.jl b/src/library/synthesis/wishart.jl index 85c21e3..0ae8afe 100644 --- a/src/library/synthesis/wishart.jl +++ b/src/library/synthesis/wishart.jl @@ -33,6 +33,8 @@ function Wishart(n::Integer, m::Integer; discretize::Bool = false, precision::In end function generate(rng, problem::Wishart{T}) where {T} + @_deprecate_generate() + f, x = PBO.wishart( rng, PBO.PBF{Int,T}, From 6687f54fd0b1ff9ece1aaf9b08c5c436c79ec667 Mon Sep 17 00:00:00 2001 From: Pedro Maciel Xavier Date: Tue, 24 Sep 2024 14:03:58 -0400 Subject: [PATCH 5/6] Add Foreign Tests for `ToQUBO`, `QUBODrivers` and `QUBO`) --- test/Project.toml | 1 + test/assets/foreign_tests.jl | 54 ++++++++++++++++++++++++ test/integration/integration.jl | 15 ++++++- test/integration/packages/packages.jl | 13 ------ test/integration/packages/qubo.jl | 9 ---- test/integration/packages/qubodrivers.jl | 9 ---- test/integration/packages/toqubo.jl | 9 ---- test/runtests.jl | 10 +++-- test/unit/library/library.jl | 2 - 9 files changed, 75 insertions(+), 47 deletions(-) create mode 100644 test/assets/foreign_tests.jl delete mode 100644 test/integration/packages/packages.jl delete mode 100644 test/integration/packages/qubo.jl delete mode 100644 test/integration/packages/qubodrivers.jl delete mode 100644 test/integration/packages/toqubo.jl diff --git a/test/Project.toml b/test/Project.toml index 29a8802..5f1ed39 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,6 +1,7 @@ [deps] Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" diff --git a/test/assets/foreign_tests.jl b/test/assets/foreign_tests.jl new file mode 100644 index 0000000..f45f0f9 --- /dev/null +++ b/test/assets/foreign_tests.jl @@ -0,0 +1,54 @@ +function run_foreign_tests()::Bool + return "--run-foreign-tests" ∈ ARGS || + Base.get_bool_env("QUBOTOOLS_FOREIGN_TESTS", false) +end + +# Test foreign packages +function test_foreign_pkg( + pkg_name::AbstractString, + dev_path::AbstractString = QUBOTools.__project__(); + test_kws..., +) + test_foreign_pkg(PackageSpec(name = pkg_name), dev_path; test_kws...) + + return nothing +end + +function test_foreign_pkg( + pkg_spec::Pkg.PackageSpec, + dev_path::AbstractString = QUBOTools.__project__(); + test_kws..., +) + @info "Activating Test Environment for '$(pkg_spec.name)'" + + Pkg.activate(; temp = true) + + Pkg.develop(; path = dev_path) + + Pkg.add(pkg_spec) + + Pkg.status() + + pkg_info = let + proj = Pkg.project() + deps = Pkg.dependencies() + + deps[proj.dependencies[pkg_spec.name]] + end + + @testset "⋆ $(pkg_info.name)@$(pkg_info.version)" begin + @test try + Pkg.test(pkg_info.name; test_kws...) + + true + catch e + if !(e isa PkgError) + rethrow(e) + end + + false + end + end + + return nothing +end diff --git a/test/integration/integration.jl b/test/integration/integration.jl index c78fa75..2ebee0e 100644 --- a/test/integration/integration.jl +++ b/test/integration/integration.jl @@ -1,10 +1,21 @@ include("ext/ext.jl") -include("packages/packages.jl") + +function test_foreign() + if run_foreign_tests() + @testset "▶ Foreign Package Tests" verbose = true begin + test_foreign_pkg(Pkg.PackageSpec(name="ToQUBO", rev="master")) + test_foreign_pkg("QUBODrivers") + test_foreign_pkg("QUBO") + end + end + + return nothing +end function test_integration() @testset "⊚ ⊚ Integration Tests" verbose = true begin test_extensions() - test_packages() + test_foreign() end return nothing diff --git a/test/integration/packages/packages.jl b/test/integration/packages/packages.jl deleted file mode 100644 index 92b752a..0000000 --- a/test/integration/packages/packages.jl +++ /dev/null @@ -1,13 +0,0 @@ -include("qubodrivers.jl") -include("toqubo.jl") -include("qubo.jl") - -function test_packages() - @testset "▶ Packages" verbose = true begin - test_qubodrivers_jl() - test_toqubo_jl() - test_qubo_jl() - end - - return nothing -end \ No newline at end of file diff --git a/test/integration/packages/qubo.jl b/test/integration/packages/qubo.jl deleted file mode 100644 index 67cc0ed..0000000 --- a/test/integration/packages/qubo.jl +++ /dev/null @@ -1,9 +0,0 @@ -""" -""" -function test_qubo_jl() - @testset "□ QUBO.jl" begin - - end - - return nothing -end \ No newline at end of file diff --git a/test/integration/packages/qubodrivers.jl b/test/integration/packages/qubodrivers.jl deleted file mode 100644 index b43548e..0000000 --- a/test/integration/packages/qubodrivers.jl +++ /dev/null @@ -1,9 +0,0 @@ -""" -""" -function test_qubodrivers_jl() - @testset "□ QUBODrivers.jl" begin - - end - - return nothing -end \ No newline at end of file diff --git a/test/integration/packages/toqubo.jl b/test/integration/packages/toqubo.jl deleted file mode 100644 index cced519..0000000 --- a/test/integration/packages/toqubo.jl +++ /dev/null @@ -1,9 +0,0 @@ -""" -""" -function test_toqubo_jl() - @testset "□ ToQUBO.jl" begin - - end - - return nothing -end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 5996f0e..656da03 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,7 @@ using Test using Printf +using Pkg +using Pkg.Types: PkgError using SparseArrays using Statistics using RecipesBase @@ -19,14 +21,16 @@ const SAT{T} = MOI.ScalarAffineTerm{T} const SQF{T} = MOI.ScalarQuadraticFunction{T} const SQT{T} = MOI.ScalarQuadraticTerm{T} -const Spin = QUBOTools.__moi_spin_set() -const QUBOModel = QUBOTools.__moi_qubo_model() -const NumberOfReads = QUBOTools.__moi_num_reads() +const QUBOTools_MOI = Base.get_extension(QUBOTools, :QUBOTools_MOI) +const Spin = QUBOTools_MOI.Spin +const QUBOModel = QUBOTools_MOI.QUBOModel +const NumberOfReads = QUBOTools_MOI.NumberOfReads const __TEST_PATH__ = @__DIR__ # Include assets include("assets/comparison.jl") +include("assets/foreign_tests.jl") # Include test functions include("unit/unit.jl") diff --git a/test/unit/library/library.jl b/test/unit/library/library.jl index 54d0125..bbc43cc 100644 --- a/test/unit/library/library.jl +++ b/test/unit/library/library.jl @@ -4,7 +4,6 @@ include("form.jl") include("model.jl") include("analysis.jl") include("formats.jl") -include("synthesis.jl") function test_library() @testset "□ Library" verbose = true begin @@ -14,7 +13,6 @@ function test_library() test_model() test_analysis() test_formats() - test_synthesis() end return nothing From 8337fed23cf2c32c51f3d79c9641953befe1ba89 Mon Sep 17 00:00:00 2001 From: Pedro Maciel Xavier Date: Tue, 24 Sep 2024 14:47:38 -0400 Subject: [PATCH 6/6] Update Julia Version --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c99896..efb6378 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: fail-fast: false matrix: include: - - version: '1.9' + - version: '1.10' os: ubuntu-latest arch: x64 - - version: '1.9' + - version: '1.10' os: windows-latest arch: x64 steps: