Skip to content

Commit

Permalink
Improved complexity of slice_intersect.
Browse files Browse the repository at this point in the history
  • Loading branch information
ymatzkevich committed Dec 12, 2024
1 parent 3e5d5a0 commit e90107f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions darts/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -5675,15 +5675,17 @@ def slice_intersect(series: Sequence[TimeSeries]) -> Sequence[TimeSeries]:
if not series:
return []

intersected_series = []
for i, ts_i in enumerate(series):
intersected_ts = ts_i
for j, ts_j in enumerate(series):
if i != j:
intersected_ts = intersected_ts.slice_intersect(ts_j)
intersected_series.append(intersected_ts)

return intersected_series
int_series = []
int_ts = series[0]
for ts in series[1:]:
int_ts = int_ts.slice_intersect(ts)
int_series.append(int_ts)

for ts in series[1:]:
ts = ts.slice_intersect(int_series[-1])
int_series.append(ts)

return int_series


def _finite_rows_boundaries(
Expand Down

0 comments on commit e90107f

Please sign in to comment.