Skip to content

Commit

Permalink
fix(BottomUp): handle constant signal and possible negative infinity …
Browse files Browse the repository at this point in the history
…cost value
  • Loading branch information
oboulant committed Jan 18, 2021
1 parent 6551903 commit f8c5367
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ruptures/utils/bnode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Binary node."""
import functools
import numpy as np


@functools.total_ordering
Expand All @@ -25,6 +26,8 @@ def gain(self):
return 0
elif abs(self.val) < 1e-8:
return 0
elif np.isinf(self.val) and self.val < 0:
return 0
return self.val - (self.left.val + self.right.val)

def __lt__(self, other):
Expand Down

0 comments on commit f8c5367

Please sign in to comment.