Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/datasets/iterable_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3581,15 +3581,12 @@ def batch(self, batch_size: int, drop_last_batch: bool = False) -> "IterableData
```
"""

def batch_fn(unbatched):
return {k: [v] for k, v in unbatched.items()}

if self.features:
features = Features({col: List(feature) for col, feature in self.features.items()})
else:
features = None
return self.map(
batch_fn, batched=True, batch_size=batch_size, drop_last_batch=drop_last_batch, features=features
_batch_fn, batched=True, batch_size=batch_size, drop_last_batch=drop_last_batch, features=features
)

def to_dict(self, batch_size: Optional[int] = None, batched: bool = False) -> Union[dict, Iterator[dict]]:
Expand Down Expand Up @@ -4659,3 +4656,7 @@ async def _apply_async(pool, func, x):
return future.get()
else:
await asyncio.sleep(0)


def _batch_fn(unbatched):
return {k: [v] for k, v in unbatched.items()}
Loading