Allow Series.intersect() to have start value
This commit is contained in:
parent
c2f17fa139
commit
68880816ac
1 changed files with 5 additions and 1 deletions
|
@ -13,13 +13,17 @@ class Series(dict):
|
|||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def intersect(self, series: Self, intersection: SeriesIntersection) -> tuple[float]:
|
||||
def intersect(self, series: Self, intersection: SeriesIntersection, start: float=None) -> tuple[float]:
|
||||
pairs = nearest(sorted(self.keys(), reverse=True),
|
||||
sorted(series.keys(), reverse=True))
|
||||
|
||||
for pair in pairs:
|
||||
v1, v2 = self[pair[0]], series[pair[1]]
|
||||
|
||||
if start is not None:
|
||||
if pair[0] > start:
|
||||
continue
|
||||
|
||||
sign = cmp(v1, v2)
|
||||
|
||||
if sign == intersection.value:
|
||||
|
|
Loading…
Add table
Reference in a new issue