From 333fdef8d3eace2ac2794646f84f50cbc94df4c3 Mon Sep 17 00:00:00 2001 From: Simon Schoelly Date: Wed, 21 May 2025 22:35:40 +0200 Subject: [PATCH 1/2] Make Julia v1.10 (LTS) min version --- .github/workflows/ci.yml | 2 +- Project.toml | 4 +--- src/Experimental/ShortestPaths/johnson.jl | 6 ++---- src/Graphs.jl | 3 --- src/Parallel/shortestpaths/johnson.jl | 7 ++----- src/core.jl | 8 +------- src/shortestpaths/johnson.jl | 4 ++-- test/runtests.jl | 17 +++++++---------- test/utils.jl | 2 +- 9 files changed, 17 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6d616b63..357a1ba2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: matrix: version: - '1' - - '1.6' + - '1.10' - 'pre' os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index 045fc8c45..83ae4a33b 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,6 @@ version = "1.12.0" [deps] ArnoldiMethod = "ec485272-7323-5ecc-a04f-4719b315124d" -Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" Inflate = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9" @@ -18,7 +17,6 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] Aqua = "0.6" ArnoldiMethod = "0.4" -Compat = "3.40, 4" DataStructures = "0.17, 0.18" Documenter = "0.27" Inflate = "0.1.3" @@ -26,7 +24,7 @@ JuliaFormatter = "1" SimpleTraits = "0.9" StableRNGs = "1" Statistics = "1" -julia = "1.6" +julia = "1.10" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" diff --git a/src/Experimental/ShortestPaths/johnson.jl b/src/Experimental/ShortestPaths/johnson.jl index 94c865927..075985ef4 100644 --- a/src/Experimental/ShortestPaths/johnson.jl +++ b/src/Experimental/ShortestPaths/johnson.jl @@ -1,7 +1,5 @@ # Currently used to support the ismutable function that is not available in Julia < v1.7 -using Compat - """ struct Johnson <: ShortestPathAlgorithm @@ -34,7 +32,7 @@ function shortest_paths( shortest_paths(g, vertices(g), distmx, BellmanFord()) ) - @compat if !ismutable(distmx) && type_distmx != Graphs.DefaultDistance + if !ismutable(distmx) && type_distmx != Graphs.DefaultDistance distmx = sparse(distmx) # Change reference, not value end @@ -58,7 +56,7 @@ function shortest_paths( dists[:, v] .+= wt_transform[v] # Vertical traversal preferred end - @compat if ismutable(distmx) + if ismutable(distmx) for e in edges(g) distmx[src(e), dst(e)] += wt_transform[dst(e)] - wt_transform[src(e)] end diff --git a/src/Graphs.jl b/src/Graphs.jl index 86bc0946a..ed96e6571 100644 --- a/src/Graphs.jl +++ b/src/Graphs.jl @@ -6,9 +6,6 @@ using SimpleTraits using ArnoldiMethod: LM, SR, LR, partialschur, partialeigen using Statistics: mean -# Currently used to support the ismutable function that is not available in Julia < v1.7 -using Compat - using Inflate: InflateGzipStream using DataStructures: IntDisjointSets, diff --git a/src/Parallel/shortestpaths/johnson.jl b/src/Parallel/shortestpaths/johnson.jl index f4fdff2ba..01352aaab 100644 --- a/src/Parallel/shortestpaths/johnson.jl +++ b/src/Parallel/shortestpaths/johnson.jl @@ -1,7 +1,4 @@ -# Currently used to support the ismutable function that is not available in Julia < v1.7 -using Compat - function johnson_shortest_paths( g::AbstractGraph{U}, distmx::AbstractMatrix{T}=weights(g) ) where {T<:Real} where {U<:Integer} @@ -10,7 +7,7 @@ function johnson_shortest_paths( # Change when parallel implementation of Bellman Ford available wt_transform = bellman_ford_shortest_paths(g, vertices(g), distmx).dists - @compat if !ismutable(distmx) && type_distmx != Graphs.DefaultDistance + if !ismutable(distmx) && type_distmx != Graphs.DefaultDistance distmx = sparse(distmx) # Change reference, not value end @@ -30,7 +27,7 @@ function johnson_shortest_paths( dists[:, v] .+= wt_transform[v] # Vertical traversal preferred end - @compat if ismutable(distmx) + if ismutable(distmx) for e in edges(g) distmx[src(e), dst(e)] += wt_transform[dst(e)] - wt_transform[src(e)] end diff --git a/src/core.jl b/src/core.jl index cb8abd175..d1329e65f 100644 --- a/src/core.jl +++ b/src/core.jl @@ -401,14 +401,8 @@ can accommodate all vertices. May also return the original graph if the eltype does not change. """ function squash(g::AbstractGraph) - - # TODO this version check can be removed when we increase the required Julia version deprecation_msg = "squash(::AbstractGraph) is deprecated in favor of methods that specialize on the graph type." - if VERSION >= v"1.5.2" - Base.depwarn(deprecation_msg, :squash; force=true) - else - Base.depwarn(deprecation_msg, :squash) - end + Base.depwarn(deprecation_msg, :squash; force=true) gtype = is_directed(g) ? DiGraph : Graph validtypes = [UInt8, UInt16, UInt32, UInt64, Int64] diff --git a/src/shortestpaths/johnson.jl b/src/shortestpaths/johnson.jl index 145d315ee..95292bd9f 100644 --- a/src/shortestpaths/johnson.jl +++ b/src/shortestpaths/johnson.jl @@ -36,7 +36,7 @@ function johnson_shortest_paths( wt_transform = bellman_ford_shortest_paths(g, collect_if_not_vector(vertices(g)), distmx).dists - @compat if !ismutable(distmx) && type_distmx != Graphs.DefaultDistance + if !ismutable(distmx) && type_distmx != Graphs.DefaultDistance distmx = sparse(distmx) # Change reference, not value end @@ -60,7 +60,7 @@ function johnson_shortest_paths( dists[:, v] .+= wt_transform[v] # Vertical traversal preferred end - @compat if ismutable(distmx) + if ismutable(distmx) for e in edges(g) distmx[src(e), dst(e)] += wt_transform[dst(e)] - wt_transform[src(e)] end diff --git a/test/runtests.jl b/test/runtests.jl index b85d4136d..77fd2230f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,7 +9,6 @@ using Graphs.Test using Test using SparseArrays using LinearAlgebra -using Compat using DelimitedFiles using Base64 using Random @@ -151,15 +150,13 @@ tests = [ @testset verbose = true "Graphs" begin @testset "Code quality (JET.jl)" begin - if VERSION >= v"1.9" - @assert get_pkg_version("JET") >= v"0.8.4" - JET.test_package( - Graphs; - target_defined_modules=true, - ignore_missing_comparison=true, - mode=:typo, # TODO: switch back to `:basic` once the union split caused by traits is fixed - ) - end + @assert get_pkg_version("JET") >= v"0.8.4" + JET.test_package( + Graphs; + target_defined_modules=true, + ignore_missing_comparison=true, + mode=:typo, # TODO: switch back to `:basic` once the union split caused by traits is fixed + ) end @testset "Code quality (Aqua.jl)" begin diff --git a/test/utils.jl b/test/utils.jl index d829018cf..44f27d574 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -38,7 +38,7 @@ @test Graphs.rng_from_rng_or_seed(nothing, nothing) === Random.GLOBAL_RNG @test Graphs.rng_from_rng_or_seed(nothing, -10) === Random.GLOBAL_RNG @test Graphs.rng_from_rng_or_seed(nothing, 456) == Graphs.getRNG(456) - @compat if ismutable(Random.GLOBAL_RNG) + if ismutable(Random.GLOBAL_RNG) @test Graphs.rng_from_rng_or_seed(nothing, 456) !== Random.GLOBAL_RNG end rng = Random.MersenneTwister(789) From d9f049e558b5406af7e5953fc324651f28716e26 Mon Sep 17 00:00:00 2001 From: Simon Schoelly Date: Wed, 21 May 2025 23:51:28 +0200 Subject: [PATCH 2/2] Add test for deprecated squash(::AbstractGraph) --- test/core.jl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/core.jl b/test/core.jl index 36d6e3f09..ccca942e2 100644 --- a/test/core.jl +++ b/test/core.jl @@ -96,4 +96,21 @@ @test @inferred(density(g)) == 0.4 end end + + @testset "squash" for (g_in, g_expected) in [ + (SimpleGraph{Int64}(), SimpleGraph{UInt8}()), + (SimpleDiGraph{UInt8}(), SimpleDiGraph{UInt8}()), + (path_graph(Int16(126)), path_graph(UInt8(126))), + (path_digraph(Int16(127)), path_digraph(UInt8(127))), + (path_graph(Int16(254)), path_graph(UInt8(254))), + (path_digraph(Int16(255)), path_digraph(UInt16(255))), + (path_graph(UInt16(255)), path_graph(UInt16(255))), + (star_graph(Int16(32766)), star_graph(UInt16(32766))), + (star_digraph(Int32(32767)), star_digraph(UInt16(32767))), + (cycle_graph(Int128(123)), cycle_graph(UInt8(123))), + ] + g_actual = squash(generic_graph(g_in)) + @test typeof(g_actual) === typeof(g_expected) + @test g_actual == g_expected + end end