Skip to content

Commit

Permalink
Fix conn and conns, export _conn and _conns
Browse files Browse the repository at this point in the history
  • Loading branch information
richardreeve committed Nov 22, 2023
1 parent 9e5e8ec commit 58e07bd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using Unitful
@traitimpl MatchBranchType{T, B} <- _matchbranchtype(T, B)

@traitdef MatchBranchNodeType{T, B, N}
@traitimpl MatchBranchNodeType{T, B, N} <- _matchbranchnodetype(T, N)
@traitimpl MatchBranchNodeType{T, B, N} <- _matchbranchnodetype(T, B, N)

@traitdef MatchTreeNameType{T, TN}
@traitimpl MatchTreeNameType{T, TN} <- _matchtreenametype(T, TN)
Expand Down Expand Up @@ -86,9 +86,8 @@ _matchbranchtype(::Type{<:AbstractTree{TT, RT, NL, N, B}},
Does this tree type prefer the branch and node types provided?
"""
function _matchbranchnodetype end
_matchbranchtype(::Type{T}, ::Type{B}, ::Type{N}) where
{TT, RT, NL, N, B, T <: AbstractTree{TT, RT, NL, N, B}} =
_matchbranchtype(T, B) && _matchnodetype(T, N)
_matchbranchnodetype(::Type{T}, ::Type{B}, ::Type{N}) where {T <: AbstractTree, B, N} =
_matchbranchtype(T, B) && _matchnodetype(T, N)

"""
_matchtreenametype(::Type{<:AbstractTree}, ::Type{X})
Expand Down
3 changes: 1 addition & 2 deletions src/LinkTree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ _src(::AbstractTree, branch::LinkBranch{<:Rooted}) = branch.inout[1]
import Phylo.API: _dst
_dst(::AbstractTree, branch::LinkBranch{<:Rooted}) = branch.inout[2]
import Phylo.API: _conn
function _conn(::AbstractTree, branch::LinkBranch{RT, NL, D},
exclude::AbstractNode{RT, NL}) where {RT, NL, D}
function _conn(::LinkTree, branch::LinkBranch, exclude::LinkNode)
return exclude branch.inout[1] ? branch.inout[2] :
(exclude branch.inout[2] ? branch.inout[1] :
error("Branch $(branch.name) not connected to $(exclude.name)"))
Expand Down
2 changes: 1 addition & 1 deletion src/Phylo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export _getconnections, _addconnection!, _removeconnection!
export MatchNodeType, MatchNodeTypes, PreferNodeObjects, _prefernodeobjects

# AbstractBranch methods
export _src, _dst, _getlength
export _src, _dst, _getlength, _conn, _conns
export MatchBranchType, PreferBranchObjects, _preferbranchobjects
export MatchBranchNodeType

Expand Down
1 change: 1 addition & 0 deletions test/test_Interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ matchbranch = true
b3 = getinbound(tree, species[2])
source = src(tree, b3)
destination = dst(tree, b3)
@test Set(conns(tree, b3)) == Set([source, conn(tree, b3, source)])
@test deletebranch!(tree, b3)
branches = [branch for branch in branches if branch != b3]
createbranch!(tree, who, species[1])
Expand Down

0 comments on commit 58e07bd

Please sign in to comment.