Skip to content

Commit

Permalink
fixed timedelta issue in longest_contiguous_slice (#725)
Browse files Browse the repository at this point in the history
* fixed timedelta issue in longest_contiguous_slice

* made slice size calculation more comprehensible
  • Loading branch information
dennisbader committed Jan 14, 2022
1 parent 3882a0c commit adde52a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ repos:
rev: 21.12b0
hooks:
- id: black-jupyter
language_version: python3.9
language_version: python3
4 changes: 3 additions & 1 deletion darts/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,9 @@ def longest_contiguous_slice(self, max_gap_size: int = 0) -> "TimeSeries":
max_slice_start = None
max_slice_end = None
for index, row in relevant_gaps.iterrows():
size = row["gap_start"] - curr_slice_start - self._freq
# evaluate size of the current slice. the slice ends one time step before row['gap_start']
curr_slice_end = row["gap_start"] - self.freq
size = curr_slice_end - curr_slice_start
if size > max_size:
max_size = size
max_slice_start = curr_slice_start
Expand Down

0 comments on commit adde52a

Please sign in to comment.