Skip to content

Commit

Permalink
Remove unnecessary Compat requirements now we've dropped Julia 0.5 co…
Browse files Browse the repository at this point in the history
…mpatibility.
  • Loading branch information
richardreeve committed Dec 19, 2017
1 parent d51ed34 commit 3593e96
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 25 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
julia 0.6
Compat 0.33.0
Distributions 0.12.2
DataStructures 0.4.3
Tokenize 0.1.0
6 changes: 2 additions & 4 deletions src/API.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/Interface.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Compat
using Phylo.API

getnodes(tree::AbstractTree) = _getnodes(tree)
Expand Down
7 changes: 3 additions & 4 deletions src/Iterators.jl
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 11 additions & 4 deletions src/Node.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
Expand All @@ -59,13 +63,15 @@ 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])]) :
(isnull(node.outbounds[2]) ? [get(node.outbounds[1])] :
[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]) :
Expand All @@ -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}()) :
Expand Down
9 changes: 4 additions & 5 deletions src/Phylo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""
Expand Down
1 change: 1 addition & 0 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
RCall 0.7.3
Compat 0.33.0
9 changes: 4 additions & 5 deletions test/test_Interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand Down

0 comments on commit 3593e96

Please sign in to comment.