Skip to content

Commit

Permalink
add getBranchRates method in TimeTree.java
Browse files Browse the repository at this point in the history
  • Loading branch information
EvaLiyt committed Jun 4, 2024
1 parent 07db152 commit 117bfad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,13 @@ public TimeTreeNode getLabeledNode(String label) {
}
return null;
}

@MethodInfo(description = "get the array of all branch rates in the tree.")
public Double[] getBranchRates(){
List<Double> branchRates = new ArrayList<>();
for (TimeTreeNode node: nodes){
branchRates.add(node.getBranchRate());
}
return branchRates.toArray(Double[]::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,13 @@ void getOldestNode() {
);
}

@Test
void getBranchRatesTest() {
Double[] branchRates = tree.getBranchRates();
List<TimeTreeNode> nodes = tree.getNodes();
for (int i = 0; i<branchRates.length; i++){
// ensure the index matching
assertEquals(nodes.get(i).getBranchRate(), branchRates[i]);
}
}
}

0 comments on commit 117bfad

Please sign in to comment.