Skip to content

Commit

Permalink
force nonnegative
Browse files Browse the repository at this point in the history
  • Loading branch information
raquellewei committed Oct 2, 2023
1 parent 2735872 commit 1140319
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fununifrac/reproducibility/Kegg_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,13 @@ def solve_branch_lengths(self, edge_length_solutions, level):
d2 = self.needed_pairs[level][(node, another)]
d3 = self.needed_pairs[level][(sib, another)]
e1 = (d1+d2-d3)/2
if e1 <= 0:
e1 = sys.float_info.epsilon
edge_length_solutions[(parent, node)] = e1
if (parent, sib) not in edge_length_solutions:
e2 = d1 - e1
if e2 <= 0:
e2 = sys.float_info.epsilon
edge_length_solutions[(parent, sib)] = e2
self.update_needed_pairs(level-1, edge_length_solutions)
self.solve_branch_lengths(edge_length_solutions, level-1)
Expand Down

0 comments on commit 1140319

Please sign in to comment.