Skip to content

Commit e311c75

Browse files
author
OpenClaw Assistant
committed
Fix #791: HuggingFaceDataset doesn't shuffle the dataset
- datasets.Dataset.shuffle() returns a new Dataset object - Need to assign the result: self._dataset = self._dataset.shuffle() - Fixed in both __init__ and shuffle() methods - Maintains backward compatibility Fixes #791
1 parent c48e0da commit e311c75

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

textattack/datasets/huggingface_dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def __init__(
149149

150150
self.shuffled = shuffle
151151
if shuffle:
152-
self._dataset.shuffle()
152+
self._dataset = self._dataset.shuffle()
153153

154154
def _format_as_dict(self, example):
155155
input_dict = collections.OrderedDict(
@@ -190,5 +190,5 @@ def __getitem__(self, i):
190190
]
191191

192192
def shuffle(self):
193-
self._dataset.shuffle()
193+
self._dataset = self._dataset.shuffle()
194194
self.shuffled = True

0 commit comments

Comments
 (0)