From c0a60f01173a96765583d693f3449ba2049c5a25 Mon Sep 17 00:00:00 2001 From: dehann Date: Sat, 29 Sep 2018 21:36:22 -0400 Subject: [PATCH] julia 1.0 and drop compat, increase DataStruct deps --- .travis.yml | 5 ++--- REQUIRE | 3 +-- src/Graphs.jl | 2 +- src/a_star_spath.jl | 6 ++---- src/adjacency_list.jl | 4 ++-- src/cliques.jl | 2 +- src/common.jl | 10 +++++----- src/concepts.jl | 2 +- src/dijkstra_spath.jl | 2 +- src/dot.jl | 4 ++-- src/edge_list.jl | 4 ++-- src/generators.jl | 2 +- src/graph.jl | 4 ++-- src/graph_visit.jl | 4 ++-- src/incidence_list.jl | 6 +++--- src/maximum_adjacency_visit.jl | 2 +- src/prim_mst.jl | 2 +- src/show.jl | 2 +- test/dot.jl | 2 -- test/dot2.jl | 3 +-- test/edgelist.jl | 2 +- test/graph.jl | 2 +- test/inclist.jl | 5 ++--- test/runtests.jl | 3 +-- 24 files changed, 37 insertions(+), 46 deletions(-) diff --git a/.travis.yml b/.travis.yml index eec63850..8c580a81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,9 @@ notifications: email: false matrix: allow_failures: - - julia: 1.0 - julia: nightly script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.build("Graphs"); Pkg.test("Graphs"; coverage=true)' + - julia --check-bounds=yes -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("Graphs"); Pkg.test("Graphs"; coverage=true)' after_success: - - julia -e 'cd(Pkg.dir("Graphs")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())' + - julia -e 'using Pkg; cd(Pkg.dir("Graphs")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())' diff --git a/REQUIRE b/REQUIRE index 3859073f..d1e4fd4b 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,3 +1,2 @@ julia 0.7 -DataStructures 0.9.0 -Compat 1.1.0 +DataStructures 0.14.0 diff --git a/src/Graphs.jl b/src/Graphs.jl index ae17b393..2f3ac7af 100644 --- a/src/Graphs.jl +++ b/src/Graphs.jl @@ -1,7 +1,7 @@ isdefined(Base, :__precompile__) && __precompile__() module Graphs -using DataStructures, Compat +using DataStructures using SparseArrays import Base: start, done, next, show, ==, < diff --git a/src/a_star_spath.jl b/src/a_star_spath.jl index 41fcc41f..c45abd4d 100644 --- a/src/a_star_spath.jl +++ b/src/a_star_spath.jl @@ -13,8 +13,6 @@ module AStar # code in its own module. using Graphs -# using Base. # in DataStructures? Julia 0.7.0 -using Compat using DataStructures export shortest_path @@ -63,8 +61,8 @@ function shortest_path( t::V, # the end vertex heuristic::Function = n -> 0) where {V,E,D} # heuristic (under)estimating distance to target # - frontier = DataStructures.PriorityQueue{@compat(Tuple{D,Array{E,1},V}),D}() - # frontier = DataStructures.PriorityQueue(@compat(Tuple{D,Array{E,1},V}),D) + frontier = DataStructures.PriorityQueue{Tuple{D,Array{E,1},V},D}() + # frontier = DataStructures.PriorityQueue(Tuple{D,Array{E,1},V},D) frontier[(zero(D), E[], s)] = zero(D) colormap = zeros(Int, num_vertices(graph)) sindx = mkindx(s) diff --git a/src/adjacency_list.jl b/src/adjacency_list.jl index 500a2f6e..cfff0ee2 100644 --- a/src/adjacency_list.jl +++ b/src/adjacency_list.jl @@ -17,8 +17,8 @@ mutable struct GenericAdjacencyList{V, VList, AdjList} <: AbstractGraph{V, Edge{ adjlist::AdjList end -@compat const SimpleAdjacencyList = GenericAdjacencyList{Int, UnitRange{Int}, Vector{Vector{Int}}} -@compat const AdjacencyList{V} = GenericAdjacencyList{V, Vector{V}, Vector{Vector{V}}} +const SimpleAdjacencyList = GenericAdjacencyList{Int, UnitRange{Int}, Vector{Vector{Int}}} +const AdjacencyList{V} = GenericAdjacencyList{V, Vector{V}, Vector{Vector{V}}} @graph_implements GenericAdjacencyList vertex_list vertex_map adjacency_list diff --git a/src/cliques.jl b/src/cliques.jl index a1f7033c..caead6e4 100644 --- a/src/cliques.jl +++ b/src/cliques.jl @@ -51,7 +51,7 @@ function maximal_cliques(g::AbstractGraph{V}) where {V} union!(cand, keys(nnbrs)) smallcand = setdiff(cand, pivotnbrs) done = Set{V}() - stack = @compat(Tuple{Set{V}, Set{V}, Set{V}})[] + stack = Tuple{Set{V}, Set{V}, Set{V}}[] clique_so_far = V[] cliques = Array{V}[] diff --git a/src/common.jl b/src/common.jl index 5999628e..9ba78f52 100644 --- a/src/common.jl +++ b/src/common.jl @@ -1,7 +1,7 @@ # Common facilities #typealias -@compat const AttributeDict = Dict{String, Any} +const AttributeDict = Dict{String, Any} ################################################# # @@ -22,7 +22,7 @@ vertex_index(v::KeyVertex) = v.index mutable struct ExVertex index::Int - label::String #Compat.UTF8String + label::String attributes::AttributeDict ExVertex(i::Int, label::AbstractString) = new(i, label, AttributeDict()) @@ -32,7 +32,7 @@ make_vertex(g::AbstractGraph{ExVertex}, label::AbstractString) = ExVertex(num_ve vertex_index(v::ExVertex) = v.index attributes(v::ExVertex, g::AbstractGraph) = v.attributes -@compat const ProvidedVertexType = @compat(Union{KeyVertex, ExVertex}) +const ProvidedVertexType = Union{KeyVertex, ExVertex} vertex_index(v::V, g::AbstractGraph{V}) where {V<:ProvidedVertexType} = vertex_index(v) @@ -59,7 +59,7 @@ struct Edge{V} target::V Edge(i::Int, s::V, t::V) where {V} = new{V}(i, s, t) end -@compat const IEdge = Edge{Int} +const IEdge = Edge{Int} # Edge{V}(i::Int, s::V, t::V) = Edge{V}(i, s, t) make_edge(g::AbstractGraph{V,E}, s::V, t::V) where {V,E<:Edge} = Edge(num_edges(g) + 1, s, t) @@ -192,7 +192,7 @@ end # ################################################ -@compat abstract type AbstractEdgePropertyInspector{T} end +abstract type AbstractEdgePropertyInspector{T} end # edge_property_requirement{T, V}(visitor::AbstractEdgePropertyInspector{T}, g::AbstractGraph{V}) = nothing diff --git a/src/concepts.jl b/src/concepts.jl index 8bc93336..1c420fd7 100644 --- a/src/concepts.jl +++ b/src/concepts.jl @@ -5,7 +5,7 @@ ################################################# ### the root type of all graphs -@compat abstract type AbstractGraph{V, E} end +abstract type AbstractGraph{V, E} end vertex_type(g::AbstractGraph{V,E}) where {V,E} = V edge_type(g::AbstractGraph{V,E}) where {V,E} = E diff --git a/src/dijkstra_spath.jl b/src/dijkstra_spath.jl index e07bd52b..1627f1bd 100644 --- a/src/dijkstra_spath.jl +++ b/src/dijkstra_spath.jl @@ -42,7 +42,7 @@ end # ################################################################### -@compat abstract type AbstractDijkstraVisitor end +abstract type AbstractDijkstraVisitor end # invoked when a new vertex is first encountered discover_vertex!(visitor::AbstractDijkstraVisitor, u, v, d) = nothing diff --git a/src/dot.jl b/src/dot.jl index ddda2b3e..8fe7a4c4 100644 --- a/src/dot.jl +++ b/src/dot.jl @@ -14,7 +14,7 @@ end function to_dot(graph::AbstractGraph, attrs::AttributeDict=AttributeDict()) str = IOBuffer() to_dot(graph, str, attrs) - @compat String(take!(str)) #takebuf_string(str) + String(take!(str)) #takebuf_string(str) end # Write the dot representation of a graph to a stream. @@ -77,7 +77,7 @@ end to_dot(attr::AbstractString, value) = "\"$attr\"=\"$value\"" -to_dot(attr_tuple::@compat Tuple{String, Any}) = "\"$(attr_tuple[1])\"=\"$(attr_tuple[2])\"" +to_dot(attr_tuple::Tuple{String, Any}) = "\"$(attr_tuple[1])\"=\"$(attr_tuple[2])\"" function graph_type_string(graph::AbstractGraph) is_directed(graph) ? "digraph" : "graph" diff --git a/src/edge_list.jl b/src/edge_list.jl index 7d024cef..a9c9990a 100644 --- a/src/edge_list.jl +++ b/src/edge_list.jl @@ -8,8 +8,8 @@ end @graph_implements GenericEdgeList vertex_list edge_list vertex_map edge_map -@compat const SimpleEdgeList{E} = GenericEdgeList{Int,E,UnitRange{Int},Vector{E}} -@compat const EdgeList{V,E} = GenericEdgeList{V,E,Vector{V},Vector{E}} +const SimpleEdgeList{E} = GenericEdgeList{Int,E,UnitRange{Int},Vector{E}} +const EdgeList{V,E} = GenericEdgeList{V,E,Vector{V},Vector{E}} # construction diff --git a/src/generators.jl b/src/generators.jl index f3ccabae..2700d996 100644 --- a/src/generators.jl +++ b/src/generators.jl @@ -81,7 +81,7 @@ function simple_wheel_graph(n::Integer; is_directed=true) return g end -function _make_simple_undirected_graph(n::T, edgelist::Vector{@compat Tuple{T,T}}) where {T<:Integer} +function _make_simple_undirected_graph(n::T, edgelist::Vector{Tuple{T,T}}) where {T<:Integer} g = simple_graph(n, is_directed=false) for (s,d) in edgelist add_edge!(g,s,d) diff --git a/src/graph.jl b/src/graph.jl index fadc539f..e11ca256 100644 --- a/src/graph.jl +++ b/src/graph.jl @@ -23,9 +23,9 @@ end # AdjList: Vector{Vector{Int}} # IncList: Vector{Vector{IEdge}} # -@compat const SimpleGraph = GenericGraph{Int,IEdge,UnitRange{Int},Vector{IEdge},Vector{Vector{IEdge}}} +const SimpleGraph = GenericGraph{Int,IEdge,UnitRange{Int},Vector{IEdge},Vector{Vector{IEdge}}} -@compat const Graph{V,E} = GenericGraph{V,E,Vector{V},Vector{E},Vector{Vector{E}}} +const Graph{V,E} = GenericGraph{V,E,Vector{V},Vector{E},Vector{Vector{E}}} # construction diff --git a/src/graph_visit.jl b/src/graph_visit.jl index cf34aef9..fcda01a8 100644 --- a/src/graph_visit.jl +++ b/src/graph_visit.jl @@ -1,6 +1,6 @@ # The concept and trivial implementation of graph visitors -@compat abstract type AbstractGraphVisitor end +abstract type AbstractGraphVisitor end # trivial implementation @@ -26,7 +26,7 @@ end # This is the common base for BreadthFirst and DepthFirst -@compat abstract type AbstractGraphVisitAlgorithm end +abstract type AbstractGraphVisitAlgorithm end ########################################################### diff --git a/src/incidence_list.jl b/src/incidence_list.jl index a9a1f0b9..d0d70c71 100644 --- a/src/incidence_list.jl +++ b/src/incidence_list.jl @@ -16,8 +16,8 @@ mutable struct GenericIncidenceList{V, E, VList, IncList} <: AbstractGraph{V, E} inclist::IncList end -@compat const SimpleIncidenceList = GenericIncidenceList{Int, IEdge, UnitRange{Int}, Vector{Vector{IEdge}}} -@compat const IncidenceList{V,E} = GenericIncidenceList{V, E, Vector{V}, Vector{Vector{E}}} +const SimpleIncidenceList = GenericIncidenceList{Int, IEdge, UnitRange{Int}, Vector{Vector{IEdge}}} +const IncidenceList{V,E} = GenericIncidenceList{V, E, Vector{V}, Vector{Vector{E}}} @graph_implements GenericIncidenceList vertex_list vertex_map edge_map adjacency_list incidence_list @@ -34,7 +34,7 @@ inclist(vs::Vector{V}; is_directed::Bool = true) where {V} = inclist(vs, Edge{V} inclist(::Type{V}; is_directed::Bool = true) where {V} = inclist(V[], Edge{V}; is_directed=is_directed) # First constructors on Dict Inc List version (reusing GenericIncidenceList container and functions, few dispatch changes required) -@compat const IncidenceDict{V,E} = GenericIncidenceList{V, E, Dict{Int,V}, Dict{Int,Vector{E}}} +const IncidenceDict{V,E} = GenericIncidenceList{V, E, Dict{Int,V}, Dict{Int,Vector{E}}} incdict(vs::Dict{Int,V}, ::Type{E}; is_directed::Bool = true) where {V,E} = IncidenceDict{V,E}(is_directed, vs, 0, Dict{Int, E}()) incdict(::Type{V}; is_directed::Bool = true) where {V} = incdict(Dict{Int,V}(), Edge{V}; is_directed=is_directed) diff --git a/src/maximum_adjacency_visit.jl b/src/maximum_adjacency_visit.jl index b62cdc70..523c13e3 100644 --- a/src/maximum_adjacency_visit.jl +++ b/src/maximum_adjacency_visit.jl @@ -10,7 +10,7 @@ mutable struct MaximumAdjacency <: AbstractGraphVisitAlgorithm end -@compat abstract type AbstractMASVisitor <: AbstractGraphVisitor end +abstract type AbstractMASVisitor <: AbstractGraphVisitor end # @static if VERSION > v"0.6-" # abstract type AbstractMASVisitor <: AbstractGraphVisitor end # else diff --git a/src/prim_mst.jl b/src/prim_mst.jl index 4246df95..c1af2d99 100644 --- a/src/prim_mst.jl +++ b/src/prim_mst.jl @@ -45,7 +45,7 @@ end # ################################################################### -@compat abstract type AbstractPrimVisitor end +abstract type AbstractPrimVisitor end # invoked when a new vertex is first encountered discover_vertex!(visitor::AbstractPrimVisitor, v, e, w) = nothing diff --git a/src/show.jl b/src/show.jl index 7787be6b..d06b73e7 100644 --- a/src/show.jl +++ b/src/show.jl @@ -8,7 +8,7 @@ function show(io::IO, v::ExVertex) end end -function show(io::IO, e::@compat(Union{Edge, ExEdge})) +function show(io::IO, e::Union{Edge, ExEdge}) print(io, "edge [$(e.index)]: $(e.source) -- $(e.target)") end diff --git a/test/dot.jl b/test/dot.jl index 89340a16..7c5822f3 100644 --- a/test/dot.jl +++ b/test/dot.jl @@ -1,8 +1,6 @@ using Graphs using Test -import Compat: xor - function has_match(regex, str) match(regex, str) !== nothing end diff --git a/test/dot2.jl b/test/dot2.jl index bebacd2a..86a7e9cd 100644 --- a/test/dot2.jl +++ b/test/dot2.jl @@ -23,7 +23,6 @@ # NOTE: if to_dot is modified to emit lines with .dot comments, these tests # mail fail erroneously.... -using Compat comRX = Base.compile(r"^[^\[]+\[([^\[]+)\]\h*$"x) function rewriteAttrs(a::AbstractString) @@ -89,7 +88,7 @@ end # module testDOT1 module testDOT2 -using Graphs, Compat +using Graphs using Test ########### diff --git a/test/edgelist.jl b/test/edgelist.jl index 49d3a0ec..2cc164bc 100644 --- a/test/edgelist.jl +++ b/test/edgelist.jl @@ -49,7 +49,7 @@ gu = simple_edgelist(5, eds; is_directed=false) ## edge list (based on vector of vertices) -for T in [ ExVertex, String ] # Compat.ASCIIString +for T in [ ExVertex, String ] g = edgelist(T[], ExEdge{T}[]) vs = [ add_vertex!(g, "a"), diff --git a/test/graph.jl b/test/graph.jl index 59a10d67..b2be9f06 100644 --- a/test/graph.jl +++ b/test/graph.jl @@ -169,7 +169,7 @@ end @testset "Extended and General directed graph" begin -for T in [ExVertex, String] #Compat.ASCIIString +for T in [ExVertex, String] ################################################# # diff --git a/test/inclist.jl b/test/inclist.jl index 4839c797..0b272461 100644 --- a/test/inclist.jl +++ b/test/inclist.jl @@ -61,8 +61,7 @@ add_edge!(gd, 4, 5) @test collect(out_edges(2, gd)) == [Edge(2, 2, 4), Edge(5, 2, 3)] @test collect(out_edges(3, gd)) == [Edge(4, 3, 4)] @test collect(out_edges(4, gd)) == [Edge(6, 4, 5)] -@test collect(out_edges(5, gd)) == Array{Tuple{Int, Int}}(undef, 0) # Array{@compat(Tuple{Int, Int})}(0) -# @test collect(out_edges(5, gd)) == Array(@compat(Tuple{Int, Int}), 0) +@test collect(out_edges(5, gd)) == Array{Tuple{Int, Int}}(undef, 0) # import Graphs: iterate # iter_state = iterate(out_neighbors(1, gd)) @@ -139,7 +138,7 @@ add_edge!(gu, 4, 5) ################################################# global g g = let g = g - for g in [inclist(KeyVertex{String}), inclist(String)] # Compat.ASCIIString, Compat.ASCIIString + for g in [inclist(KeyVertex{String}), inclist(String)] global vs = [ add_vertex!(g, "a"), add_vertex!(g, "b"), add_vertex!(g, "c") ] diff --git a/test/runtests.jl b/test/runtests.jl index bb178076..00e4084c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,4 @@ -using Compat -# import Compat.String + tests = [ "edgelist",