From 3593e96719ebdc071086d442eb0bc805c0ad6c0e Mon Sep 17 00:00:00 2001 From: Richard Reeve Date: Tue, 19 Dec 2017 22:59:43 +0000 Subject: [PATCH] Remove unnecessary Compat requirements now we've dropped Julia 0.5 compatibility. --- README.md | 4 +++- REQUIRE | 1 - src/API.jl | 6 ++---- src/Interface.jl | 1 - src/Iterators.jl | 7 +++---- src/Node.jl | 15 +++++++++++---- src/Phylo.jl | 9 ++++----- test/REQUIRE | 1 + test/test_Interface.jl | 9 ++++----- 9 files changed, 28 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 7b3f8f7c..b13a2964 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,9 @@ julia> Pkg.add("Phylo") ## Project Status -The package is tested against the current Julia `0.6` release, and `nightly` on Linux, OS X, and Windows. +The package is tested against the current Julia `0.6` release, and +`nightly` on Linux, OS X, and Windows. It is currently broken on +nightly due to changes to Nullable handling, but this will be fixed soon... ## Contributing and Questions diff --git a/REQUIRE b/REQUIRE index f36a63f4..a8c4d3dc 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,4 @@ julia 0.6 -Compat 0.33.0 Distributions 0.12.2 DataStructures 0.4.3 Tokenize 0.1.0 diff --git a/src/API.jl b/src/API.jl index 50a5c2de..afaba1d7 100644 --- a/src/API.jl +++ b/src/API.jl @@ -1,14 +1,12 @@ using Phylo -using Compat function _newlabel(ids::Vector{Label}) where Label <: Integer return isempty(ids) ? 1 : maximum(ids) + 1 end function _newlabel(names::Vector{String}, prefix) - names = collect(Compat.Iterators.filter(n -> length(n) > length(prefix) && - n[1:length(prefix)]==prefix, - names)) + names = collect(Iterators.filter(n -> length(n) > length(prefix) && + n[1:length(prefix)]==prefix, names)) start = length(names) + 1 name = prefix * "$start" while (name ∈ names) diff --git a/src/Interface.jl b/src/Interface.jl index 6f625b5a..27d450e1 100644 --- a/src/Interface.jl +++ b/src/Interface.jl @@ -1,4 +1,3 @@ -using Compat using Phylo.API getnodes(tree::AbstractTree) = _getnodes(tree) diff --git a/src/Iterators.jl b/src/Iterators.jl index 0fd05240..8eba1f77 100644 --- a/src/Iterators.jl +++ b/src/Iterators.jl @@ -1,7 +1,6 @@ -using Compat using Phylo.API -@compat abstract type AbstractTreeIterator{T <: AbstractTree} end +abstract type AbstractTreeIterator{T <: AbstractTree} end function iteratorsize(::Type{AbstractTreeIterator}) return Base.HasLength() @@ -11,7 +10,7 @@ function iteratoreltype(::Type{AbstractTreeIterator}) return Base.HasEltype() end -@compat abstract type AbstractNodeIterator{T <: AbstractTree} <: AbstractTreeIterator{T} end +abstract type AbstractNodeIterator{T <: AbstractTree} <: AbstractTreeIterator{T} end function start(ni::It) where It <: AbstractNodeIterator nodes = _getnodes(ni.tree) @@ -44,7 +43,7 @@ function length(ni::It) where It <: AbstractNodeIterator end -@compat abstract type AbstractBranchIterator{T <: AbstractTree} <: AbstractTreeIterator{T} end +abstract type AbstractBranchIterator{T <: AbstractTree} <: AbstractTreeIterator{T} end function start(bi::It) where It <: AbstractBranchIterator branches = _getbranches(bi.tree) diff --git a/src/Node.jl b/src/Node.jl index 71110d6f..3097a121 100644 --- a/src/Node.jl +++ b/src/Node.jl @@ -1,7 +1,3 @@ -using Compat -import Phylo.API: _hasinbound, _getinbound, _setinbound!, _deleteinbound! -import Phylo.API: _outdegree, _hasoutboundspace, _getoutbounds, _addoutbound!, _deleteoutbound! - """ BinaryNode{T}(AbstractVector{T}, AbstractVector{T}) <: AbstractNode @@ -26,31 +22,39 @@ mutable struct BinaryNode{T} <: AbstractNode end end +import Phylo.API._hasinbound function _hasinbound(node::BinaryNode) return !isnull(node.inbound) end + +import Phylo.API._outdegree function _outdegree(node::BinaryNode) return (isnull(node.outbounds[1]) ? 0 : 1) + (isnull(node.outbounds[2]) ? 0 : 1) end + +import Phylo.API._hasoutboundspace function _hasoutboundspace(node::BinaryNode) return _outdegree(node) < 2 end +import Phylo.API._getinbound function _getinbound(node::BinaryNode) _hasinbound(node) || error("Node has no inbound connection") return get(node.inbound) end +import Phylo.API._setinbound! function _setinbound!(node::BinaryNode{T}, inbound::T) where T !_hasinbound(node) || error("BinaryNode already has an inbound connection") node.inbound = inbound end +import Phylo.API._deleteinbound! function _deleteinbound!(node::BinaryNode{T}, inbound::T) where T _hasinbound(node) || error("Node has no inbound connection") @@ -59,6 +63,7 @@ function _deleteinbound!(node::BinaryNode{T}, inbound::T) where T node.inbound = Nullable{T}() end +import Phylo.API._getoutbounds function _getoutbounds(node::BinaryNode{T}) where T return isnull(node.outbounds[1]) ? (isnull(node.outbounds[2]) ? T[] : [get(node.outbounds[2])]) : @@ -66,6 +71,7 @@ function _getoutbounds(node::BinaryNode{T}) where T [get(node.outbounds[1]), get(node.outbounds[2])]) end +import Phylo.API._addoutbound! function _addoutbound!(node::BinaryNode{T}, outbound::T) where T isnull(node.outbounds[1]) ? node.outbounds = (Nullable(outbound), node.outbounds[2]) : @@ -74,6 +80,7 @@ function _addoutbound!(node::BinaryNode{T}, outbound::T) where T error("BinaryNode already has two outbound connections")) end +import Phylo.API._deleteoutbound! function _deleteoutbound!(node::BinaryNode{T}, outbound::T) where T !isnull(node.outbounds[1]) && get(node.outbounds[1]) == outbound ? node.outbounds = (node.outbounds[2], Nullable{T}()) : diff --git a/src/Phylo.jl b/src/Phylo.jl index 00ec2726..55150035 100644 --- a/src/Phylo.jl +++ b/src/Phylo.jl @@ -13,14 +13,13 @@ a simple phylogenetics type. """ module Phylo -using Compat import Base: Pair, Tuple, show, showall, start, next, done, iteratorsize, iteratoreltype, eltype, length -@compat abstract type AbstractNode end -@compat abstract type AbstractBranch end -@compat abstract type AbstractTree{NodeLabel, BranchLabel} end -@compat abstract type AbstractInfo end +abstract type AbstractNode end +abstract type AbstractBranch end +abstract type AbstractTree{NodeLabel, BranchLabel} end +abstract type AbstractInfo end export AbstractNode, AbstractBranch, AbstractTree, AbstractInfo """ diff --git a/test/REQUIRE b/test/REQUIRE index 8625e0c6..fcbfc1be 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1 +1,2 @@ RCall 0.7.3 +Compat 0.33.0 diff --git a/test/test_Interface.jl b/test/test_Interface.jl index a120c04e..da8c89e8 100644 --- a/test/test_Interface.jl +++ b/test/test_Interface.jl @@ -2,7 +2,6 @@ module TestInterface using Phylo using Compat.Test -using Compat @testset "Build and tear down trees" begin @testset "For $TreeType" for TreeType in @@ -31,9 +30,9 @@ using Compat pop!(innodes) branches = map(innodes) do node - itr = Compat.Iterators.filter(name -> - hasoutboundspace(tree, name) && - name != node, allnodes) + itr = Iterators.filter(name -> + hasoutboundspace(tree, name) && + name != node, allnodes) addbranch!(tree, first(itr), node) end @test Set(branches) == Set(branchnameiter(tree)) @@ -56,7 +55,7 @@ using Compat outdegree(tree, species[1]) == 0 && indegree(tree, species[1]) == 0 @test_throws ErrorException getbranch(tree, b) - branches = collect(Compat.Iterators.filter(name -> name != b, branches)) + branches = collect(Iterators.filter(name -> name != b, branches)) @test Set(branches) == Set(branchnameiter(tree)) b3 = getinbound(tree, species[2]) source = src(tree, b3)