Skip to content

Commit adde52a

Browse files
authored
fixed timedelta issue in longest_contiguous_slice (#725)
* fixed timedelta issue in longest_contiguous_slice * made slice size calculation more comprehensible
1 parent 3882a0c commit adde52a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ repos:
33
rev: 21.12b0
44
hooks:
55
- id: black-jupyter
6-
language_version: python3.9
6+
language_version: python3

darts/timeseries.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,9 @@ def longest_contiguous_slice(self, max_gap_size: int = 0) -> "TimeSeries":
16531653
max_slice_start = None
16541654
max_slice_end = None
16551655
for index, row in relevant_gaps.iterrows():
1656-
size = row["gap_start"] - curr_slice_start - self._freq
1656+
# evaluate size of the current slice. the slice ends one time step before row['gap_start']
1657+
curr_slice_end = row["gap_start"] - self.freq
1658+
size = curr_slice_end - curr_slice_start
16571659
if size > max_size:
16581660
max_size = size
16591661
max_slice_start = curr_slice_start

0 commit comments

Comments
 (0)