Skip to content

Commit 6756864

Browse files
jlapeyregdalle
andauthored
Add JET.jl to testsuite (#249)
* Add JET.jl to testsuite * Add JET to extras and target in Project.toml * Add a file ./test/jet_test.jl * Include this test in runtests.jl conditioned on Julia version >= 1.7 * Fix JET warnings and use JET.test_package * using JET * Fix JET bug * Fix most warnings from JET and linter * Fix LinAlg deprecation to None * Only one JET error remains on fadj/badj * Custom hack for SimpleDiGraph equality to satisfy JET * Fix tests * Upgrate JET to 0.8.2 * Check JET version before testing (>= 0.8.3 on Julia 1.9) * Fix test dependencies * Make sure that JET runs on Julia >= 1.9 --------- Co-authored-by: Guillaume Dalle <[email protected]>
1 parent e5405d1 commit 6756864

File tree

10 files changed

+90
-55
lines changed

10 files changed

+90
-55
lines changed

Project.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1616
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1717

1818
[compat]
19-
Aqua = "0.5"
19+
Aqua = "0.6"
2020
ArnoldiMethod = "0.1, 0.2"
2121
Compat = "3.40, 4"
2222
DataStructures = "0.17, 0.18"
@@ -32,9 +32,15 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3232
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
3333
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
3434
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
35+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
3536
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
37+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
38+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
39+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
40+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
3641
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
42+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
3743
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3844

3945
[targets]
40-
test = ["Aqua", "Base64", "DelimitedFiles", "Documenter", "JuliaFormatter", "StableRNGs", "Test"]
46+
test = ["Aqua", "Base64", "DelimitedFiles", "Documenter", "JET", "JuliaFormatter", "LinearAlgebra", "Pkg", "Random", "SparseArrays", "StableRNGs", "Statistics", "Test"]

src/Experimental/vf2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ function all_isomorph(
658658
edge_relation::Union{Nothing,Function}=nothing,
659659
)::Channel{Vector{Tuple{eltype(g1),eltype(g2)}}}
660660
T = Vector{Tuple{eltype(g1),eltype(g2)}}
661-
!could_have_isomorph(g1, g2) && return Channel(_ -> return, ctype = T) # TODO: fix problem with JuliaFormatter, right now the whole file is ignored
661+
!could_have_isomorph(g1, g2) && return Channel(_ -> nothing, ctype = T) # TODO: fix problem with JuliaFormatter, right now the whole file is ignored
662662
make_callback(c) = vmap -> (put!(c, collect(zip(vmap, 1:length(vmap)))), return true)
663663
ch::Channel{T} = Channel(; ctype=T) do c
664664
vf2(

src/SimpleGraphs/SimpleGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ edges(g::AbstractSimpleGraph) = SimpleEdgeIter(g)
142142
fadj(g::AbstractSimpleGraph) = g.fadjlist
143143
fadj(g::AbstractSimpleGraph, v::Integer) = g.fadjlist[v]
144144

145-
badj(x...) = _NI("badj")
145+
function badj end
146146

147147
# handles single-argument edge constructors such as pairs and tuples
148148
has_edge(g::AbstractSimpleGraph, x) = has_edge(g, edgetype(g)(x))
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
@deprecate BullGraph bull_graph
2-
@deprecate ChvatalGraph chvatal_graph
3-
@deprecate CubicalGraph cubical_graph
4-
@deprecate DesarguesGraph desargues_graph
5-
@deprecate DiamondGraph diamond_graph
6-
@deprecate DodecahedralGraph dodecahedral_graph
7-
@deprecate FruchtGraph frucht_graph
8-
@deprecate HeawoodGraph heawood_graph
9-
@deprecate HouseGraph house_graph
10-
@deprecate HouseXGraph house_x_graph
11-
@deprecate IcosahedralGraph icosahedral_graph
12-
@deprecate KarateGraph karate_graph
13-
@deprecate KrackhardtKiteGraph krackhardt_kite_graph
14-
@deprecate MoebiusKantorGraph moebius_kantor_graph
15-
@deprecate OctahedralGraph octahedral_graph
16-
@deprecate PappusGraph pappus_graph
17-
@deprecate PetersenGraph petersen_graph
18-
@deprecate SedgewickMazeGraph sedgewick_maze_graph
19-
@deprecate TetrahedralGraph tetrahedral_graph
20-
@deprecate TruncatedCubeGraph truncated_cube_graph
21-
@deprecate TruncatedTetrahedronGraph truncated_tetrahedron_graph
22-
@deprecate TruncatedTetrahedronDiGraph truncated_tetrahedron_digraph
23-
@deprecate TutteGraph tutte_graph
24-
@deprecate CompleteGraph complete_graph
25-
@deprecate CompleteBipartiteGraph complete_bipartite_graph
26-
@deprecate CompleteMultipartiteGraph complete_multipartite_graph
27-
@deprecate TuranGraph turan_graph
28-
@deprecate CompleteDiGraph complete_digraph
29-
@deprecate StarGraph star_graph
30-
@deprecate StarDigraph star_digraph
31-
@deprecate PathGraph path_graph
32-
@deprecate PathDiGraph path_digraph
33-
@deprecate CycleGraph cycle_graph
34-
@deprecate CycleDiGraph cycle_digraph
35-
@deprecate WheelGraph wheel_graph
36-
@deprecate WheelDiGraph wheel_digraph
37-
@deprecate Grid grid
38-
@deprecate BinaryTree binary_tree
39-
@deprecate Doublebinary_tree double_binary_tree
40-
@deprecate RoachGraph roach_graph
41-
@deprecate CliqueGraph clique_graph
42-
@deprecate LadderGraph ladder_graph
43-
@deprecate Circularladder_graph circular_ladder_graph
44-
@deprecate BarbellGraph barbell_graph
45-
@deprecate LollipopGraph lollipop_graph
1+
@deprecate BullGraph() bull_graph()
2+
@deprecate ChvatalGraph() chvatal_graph()
3+
@deprecate CubicalGraph() cubical_graph()
4+
@deprecate DesarguesGraph() desargues_graph()
5+
@deprecate DiamondGraph() diamond_graph()
6+
@deprecate DodecahedralGraph() dodecahedral_graph()
7+
@deprecate FruchtGraph() frucht_graph()
8+
@deprecate HeawoodGraph() heawood_graph()
9+
@deprecate HouseGraph() house_graph()
10+
@deprecate HouseXGraph() house_x_graph()
11+
@deprecate IcosahedralGraph() icosahedral_graph()
12+
@deprecate KarateGraph() karate_graph()
13+
@deprecate KrackhardtKiteGraph() krackhardt_kite_graph()
14+
@deprecate MoebiusKantorGraph() moebius_kantor_graph()
15+
@deprecate OctahedralGraph() octahedral_graph()
16+
@deprecate PappusGraph() pappus_graph()
17+
@deprecate PetersenGraph() petersen_graph()
18+
@deprecate SedgewickMazeGraph() sedgewick_maze_graph()
19+
@deprecate TetrahedralGraph() tetrahedral_graph()
20+
@deprecate TruncatedCubeGraph() truncated_cube_graph()
21+
@deprecate TruncatedTetrahedronGraph() truncated_tetrahedron_graph()
22+
@deprecate TruncatedTetrahedronDiGraph() truncated_tetrahedron_digraph()
23+
@deprecate TutteGraph() tutte_graph()
24+
@deprecate CompleteGraph(n) complete_graph(n)
25+
@deprecate CompleteBipartiteGraph(n1, n2) complete_bipartite_graph(n1, n2)
26+
@deprecate CompleteMultipartiteGraph(partitions) complete_multipartite_graph(partitions)
27+
@deprecate TuranGraph(n, r) turan_graph(n, r)
28+
@deprecate CompleteDiGraph(n) complete_digraph(n)
29+
@deprecate StarGraph(n) star_graph(n)
30+
@deprecate StarDigraph(n) star_digraph(n)
31+
@deprecate PathGraph(n) path_graph(n)
32+
@deprecate PathDiGraph(n) path_digraph(n)
33+
@deprecate CycleGraph(n) cycle_graph(n)
34+
@deprecate CycleDiGraph(n) cycle_digraph(n)
35+
@deprecate WheelGraph(n) wheel_graph(n)
36+
@deprecate WheelDiGraph(n) wheel_digraph(n)
37+
@deprecate Grid(dims; periodic=false) grid(dims; periodic=false)
38+
@deprecate BinaryTree(k) binary_tree(k)
39+
@deprecate Doublebinary_tree(k) double_binary_tree(k)
40+
@deprecate RoachGraph(k) roach_graph(k)
41+
@deprecate CliqueGraph(k, n) clique_graph(k, n)
42+
@deprecate LadderGraph(n) ladder_graph(n)
43+
@deprecate Circularladder_graph(n) circular_ladder_graph(n)
44+
@deprecate BarbellGraph(n1, n2) barbell_graph(n1, n2)
45+
@deprecate LollipopGraph(n1, n2) lollipop_graph(n1, n2)

src/deprecations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# for which the deprecation should be removed.
33

44
# Deprecated to fix spelling. Can be removed for version 2.0.
5-
@deprecate simplecycles_hadwick_james simplecycles_hawick_james
5+
@deprecate simplecycles_hadwick_james(g) simplecycles_hawick_james(g)
66

77
# Deprecated for more explicit function name. Can be removed for version 2.0.
88
@deprecate saw self_avoiding_walk

src/graphcut/normalized_cut.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function _partition_weightmx(cut, W::SparseMatrixCSC)
115115
return (W1, W2, vmap1, vmap2)
116116
end
117117

118-
function _recursive_normalized_cut(W, thres=thres, num_cuts=num_cuts)
118+
function _recursive_normalized_cut(W, thres, num_cuts)
119119
m, n = size(W)
120120
D = Diagonal(vec(sum(W; dims=2)))
121121

src/linalg/graphmatrices.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ function symmetrize(adjmat::CombinatorialAdjacency, which=:or)
306306
end
307307

308308
# per #564
309-
# @deprecate mul!(Y, A::Noop, B) None
310-
@deprecate convert(::Type{Adjacency}, lapl::Laplacian) None
309+
# @deprecate mul!(Y, A::Noop, B) nothing
310+
@deprecate convert(::Type{Adjacency}, lapl::Laplacian) nothing
311311
@deprecate convert(::Type{SparseMatrix}, adjmat::GraphMatrix) sparse(adjmat)
312312

313313
"""

src/operators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ function crosspath end
394394
len::Integer, g::AG::(!IsDirected)
395395
) where {T,AG<:AbstractGraph{T}}
396396
p = path_graph(len)
397-
h = Graph{T}(p)
397+
h = SimpleGraph{T}(p)
398398
return cartesian_product(h, g)
399399
end
400400

test/runtests.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using Documenter
33
using Graphs
44
using Graphs.SimpleGraphs
55
using Graphs.Experimental
6+
using JET
67
using JuliaFormatter
78
using Graphs.Test
89
using Test
@@ -14,9 +15,26 @@ using Base64
1415
using Random
1516
using Statistics: mean, std
1617
using StableRNGs
18+
using Pkg
1719

1820
const testdir = dirname(@__FILE__)
1921

22+
function get_pkg_version(name::AbstractString)
23+
for dep in values(Pkg.dependencies())
24+
if dep.name == name
25+
return dep.version
26+
end
27+
end
28+
return error("Dependency not available")
29+
end
30+
31+
@testset "Code quality (JET.jl)" begin
32+
if VERSION >= v"1.9"
33+
@assert get_pkg_version("JET") >= v"0.8.3"
34+
JET.test_package(Graphs; target_defined_modules=true)
35+
end
36+
end
37+
2038
@testset verbose = true "Code quality (Aqua.jl)" begin
2139
Aqua.test_all(Graphs; ambiguities=false)
2240
end

test/simplegraphs/simplegraphs.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using Random: Random
99
@test @inferred(eltype(SimpleGraph(adjmx1))) == Int
1010
@test_throws ArgumentError SimpleGraph(adjmx2)
1111

12-
@test_throws Graphs.NotImplementedError badj(DummySimpleGraph())
12+
@test_throws MethodError badj(DummySimpleGraph())
1313

1414
@test @inferred(ne(SimpleGraph(path_digraph(5)))) == 4
1515
@test @inferred(!is_directed(SimpleGraph))
@@ -498,4 +498,15 @@ using Random: Random
498498
end
499499
# codecov for has_edge(::AbstractSimpleGraph, x, y)
500500
@test @inferred has_edge(DummySimpleGraph(), 1, 2)
501+
502+
# Test for SimpleDiGraph equality #249
503+
@test SimpleGraph(1) != SimpleGraph(0)
504+
@test SimpleGraph(1) != SimpleGraph(2)
505+
@test SimpleGraph(2) != SimpleDiGraphFromIterator(Edge.([(1, 2)]))
506+
@test SimpleDiGraphFromIterator(Edge.([(1, 2)])) !=
507+
SimpleDiGraphFromIterator(Edge.([(2, 1)]))
508+
@test SimpleDiGraphFromIterator(Edge.([(1, 2), (2, 3)])) !=
509+
SimpleDiGraphFromIterator(Edge.([(1, 2), (3, 2)]))
510+
@test SimpleDiGraphFromIterator(Edge.([(1, 2), (2, 3)])) !=
511+
SimpleDiGraphFromIterator(Edge.([(1, 2), (1, 3)]))
501512
end

0 commit comments

Comments
 (0)