Skip to content

Commit

Permalink
Add: with_split
Browse files Browse the repository at this point in the history
  • Loading branch information
jp1924 committed Oct 19, 2024
1 parent d4422cc commit 6392274
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/datasets/dataset_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ def map(
function: Optional[Callable] = None,
with_indices: bool = False,
with_rank: bool = False,
with_split: bool = False,
input_columns: Optional[Union[str, List[str]]] = None,
batched: bool = False,
batch_size: Optional[int] = 1000,
Expand All @@ -795,7 +796,7 @@ def map(
writer_batch_size: Optional[int] = 1000,
features: Optional[Features] = None,
disable_nullable: bool = False,
fn_kwargs: Optional[dict] = None,
fn_kwargs: dict = {},
num_proc: Optional[int] = None,
desc: Optional[str] = None,
) -> "DatasetDict":
Expand Down Expand Up @@ -882,6 +883,7 @@ def map(
self._check_values_type()
if cache_file_names is None:
cache_file_names = {k: None for k in self}

return DatasetDict(
{
k: dataset.map(
Expand All @@ -899,7 +901,7 @@ def map(
writer_batch_size=writer_batch_size,
features=features,
disable_nullable=disable_nullable,
fn_kwargs=fn_kwargs,
fn_kwargs={**fn_kwargs, "split": k} if with_split else fn_kwargs,
num_proc=num_proc,
desc=desc,
)
Expand Down

0 comments on commit 6392274

Please sign in to comment.