mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-28 15:08:37 +08:00
Fix iteration over HF dataset collection
This commit is contained in:
parent
78c33e5037
commit
a4a86ad898
@ -90,7 +90,8 @@ class CompletionsDatasetCollection:
|
|||||||
self.collection = data
|
self.collection = data
|
||||||
|
|
||||||
def __getitem__(self, idx: int):
|
def __getitem__(self, idx: int):
|
||||||
item = next(self.collection)
|
iteration = iter(self.collection)
|
||||||
|
item = next(iteration)
|
||||||
|
|
||||||
curr_idx = idx
|
curr_idx = idx
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ class CompletionsDatasetCollection:
|
|||||||
return item[curr_idx]
|
return item[curr_idx]
|
||||||
else:
|
else:
|
||||||
curr_idx -= len(item)
|
curr_idx -= len(item)
|
||||||
item = next(self.collection)
|
item = next(iteration)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise IndexError(idx)
|
raise IndexError(idx)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user