Skip to content

Commit

Permalink
Fix TSDataSampler Slicing Bug #1716
Browse files Browse the repository at this point in the history
  • Loading branch information
YeewahChan committed Jun 3, 2024
1 parent edf1fdb commit 62d6720
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion qlib/data/dataset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ def __getitem__(self, idx: Union[int, Tuple[object, str], List[int]]):
indices = np.nan_to_num(indices.astype(np.float64), nan=self.nan_idx).astype(int)

if (np.diff(indices) == 1).all(): # slicing instead of indexing for speeding up.
if indices[0] < 0 :
if indices[0] == -1 :
data = self.data_arr[0 : indices[-1] + 1]
# Prepend nan values to the data to match the step_len
data = np.concatenate([np.full((self.step_len - len(data), *data.shape[1:]), np.nan), data])
Expand Down

0 comments on commit 62d6720

Please sign in to comment.