From 735537c7923f399aadb124983da0caf6a9c62964 Mon Sep 17 00:00:00 2001 From: Jorge Fernandez-de-Cossio-Diaz Date: Thu, 6 Jul 2023 12:17:41 +0200 Subject: [PATCH 1/2] Interface.jl --- src/Interface.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Interface.jl b/src/Interface.jl index caa2556f..7d7a675e 100644 --- a/src/Interface.jl +++ b/src/Interface.jl @@ -328,7 +328,7 @@ function createbranch! end error("Tree does not have an available destination node called " * _getnodename(tree, dn)) sn ≢ dn || error("Branch must connect different nodes") - + return ismissing(data) ? _createbranch!(tree, sn, dn, len, name) : _createbranch!(tree, sn, dn, len, name, data) @@ -348,7 +348,7 @@ end error("Tree does not have an available destination node called " * _getnodename(tree, dst)) src ≢ dst || error("Branch must connect different nodes") - + return ismissing(data) ? _createbranch!(tree, src, dst, len, name) : _createbranch!(tree, src, dst, len, name, data) @@ -371,7 +371,7 @@ end error("Tree does not have an available destination node called " * _getnodename(tree, dn)) sn ≢ dn || error("Branch must connect different nodes") - + return ismissing(data) ? _createbranch!(tree, sn, dn, len, name) : _createbranch!(tree, sn, dn, len, name, data) @@ -392,7 +392,7 @@ end error("Tree does not have an available destination node called " * _getnodename(tree, dst)) src ≢ dst || error("Branch must connect different nodes") - + return ismissing(data) ? _createbranch!(tree, src, dst, len, name) : _createbranch!(tree, src, dst, len, name, data) @@ -644,7 +644,7 @@ function isleaf end end @traitfn function isleaf(tree::T, node::N) where {T <: AbstractTree{OneTree}, N; MatchNodeType{T, N}} - _hasnode(tree, node) || error("Node $node does not exist") + _hasnode(tree, node) || error("Node $node does not exist") return _isleaf(tree, node) end @@ -1036,12 +1036,12 @@ Return the length of this branch. """ function getlength end @traitfn function getlength(tree::T, branch::B) where - {T <: AbstractTree{OneTree}, B, N; !MatchBranchType{T, B}} + {T <: AbstractTree{OneTree}, B; !MatchBranchType{T, B}} hasbranch(tree, branch) || error("Branch $branch does not exist") return _getlength(tree, _getbranch(tree, branch)) end @traitfn function getlength(tree::T, branch::B) where - {T <: AbstractTree{OneTree}, B, N; MatchBranchType{T, B}} + {T <: AbstractTree{OneTree}, B; MatchBranchType{T, B}} _hasbranch(tree, branch) || error("Branch $branch does not exist") return _getlength(tree, branch) end From 98e23bf1ef4c57e880741e2061ddbba398c8eca8 Mon Sep 17 00:00:00 2001 From: Jorge Fernandez-de-Cossio-Diaz Date: Thu, 6 Jul 2023 12:19:51 +0200 Subject: [PATCH 2/2] others --- src/Tree.jl | 4 ++-- src/plot.jl | 10 +++++----- src/routes.jl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Tree.jl b/src/Tree.jl index d559b2d1..16193665 100644 --- a/src/Tree.jl +++ b/src/Tree.jl @@ -7,7 +7,7 @@ abstract type AbstractBranchTree{RT, N, B, LI, ND} <: end import Phylo.API: _hasinbound -function _hasinbound(tree::AbstractBranchTree{<: Rooted}, name::String) +function _hasinbound(tree::AbstractBranchTree{<: Rooted}, name::String) return tree.nodes[name].inbound !== nothing end @@ -429,7 +429,7 @@ end import Phylo.API: _addoutbound! function _addoutbound!(tree::BinaryTree{RT}, name::String, branch::B) where - {RT <: Rooted, N, B <: Branch{RT, String}} + {RT <: Rooted, B <: Branch{RT, String}} node = tree.nodes[name] node.outbounds[1] ≡ nothing ? node.outbounds = (branch, node.outbounds[2]) : diff --git a/src/plot.jl b/src/plot.jl index 4314c1ac..43b62e87 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -152,7 +152,7 @@ end _handlez(x, tree, names) = x _handlez(x::Union{String, Symbol}, tree, names) = [getnodedata(tree, name, x) for name in names] -function _handlez(x::Dict, tree, names) where T +function _handlez(x::Dict, tree, names) ret = fill(NaN, length(names)) for (i, n) in enumerate(names) name = getnodename(tree, n) @@ -293,10 +293,10 @@ end """ map_depthfirst(FUN, start, tree, eltype = nothing) -Apply `FUN` to each node in `tree` in depth-first order, and return the result. -`FUN` must take two arguments, `val` and `node`, where `val` is the result of -applying `FUN` to the previous node, and `node` is the current node. `start` -specifies the initial value of `val`, and `eltype` specifies the type of the +Apply `FUN` to each node in `tree` in depth-first order, and return the result. +`FUN` must take two arguments, `val` and `node`, where `val` is the result of +applying `FUN` to the previous node, and `node` is the current node. `start` +specifies the initial value of `val`, and `eltype` specifies the type of the return value of `FUN`. ### Examples diff --git a/src/routes.jl b/src/routes.jl index 1627df19..ce394ef1 100644 --- a/src/routes.jl +++ b/src/routes.jl @@ -160,7 +160,7 @@ function noderoute end return [getnodename(tree, n) for n in route] end @traitfn function noderoute(tree::T, node1::N, node2::N) where - {RT, N, T <: AbstractTree{OneTree}; MatchNodeType{T, N}} + {N, T <: AbstractTree{OneTree}; MatchNodeType{T, N}} branches1, nodes1 = _treehistory(tree, node1) branches2, nodes2 = _treehistory(tree, node2) nodes1[end] == nodes2[end] || error("No route between nodes in tree")