'''simple docstring'''
import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict







@pytest.mark.parametrize(
    'split_dict'				,     [
        SplitDict(),
        SplitDict({'train': SplitInfo(name='train'				,     num_bytes=1_3_3_7				,     num_examples=4_2				,     dataset_name='my_dataset'			)}			),
        SplitDict({'train': SplitInfo(name='train'				,     num_bytes=1_3_3_7				,     num_examples=4_2			)}			),
        SplitDict({'train': SplitInfo()}			),
    ]				,     )
def  _UpperCamelCase (     _a	:	SplitDict			):




    """simple docstring"""



    __UpperCamelCase	:	Optional[Any]		    =  split_dict._to_yaml_list()
    assert len(_a			) == len(_a			)
    __UpperCamelCase	:	List[str]		    =  SplitDict._from_yaml_list(_a			)
    for split_name, split_info in split_dict.items():
        # dataset_name field is deprecated, and is therefore not part of the YAML dump
        __UpperCamelCase	:	Any		    =  None
        # the split name of split_dict takes over the name of the split info object
        __UpperCamelCase	:	Any		    =  split_name
    assert split_dict == reloaded







@pytest.mark.parametrize(
    'split_info'				,     [SplitInfo(), SplitInfo(dataset_name=_a			), SplitInfo(dataset_name='my_dataset'			)]			)
def  _UpperCamelCase (     _a	:	Any			):




    """simple docstring"""



    __UpperCamelCase	:	List[str]		    =  asdict(SplitDict({'train': split_info}			)			)
    assert "dataset_name" in split_dict_asdict["train"]
    assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name




'''simple docstring'''
from urllib.parse import quote

import pytest

from datasets.utils.hub import hf_hub_url







@pytest.mark.parametrize('repo_id'				,     ['canonical_dataset_name', 'org-name/dataset-name']			)
@pytest.mark.parametrize('path'				,     ['filename.csv', 'filename with blanks.csv']			)
@pytest.mark.parametrize('revision'				,     [None, 'v2']			)
def  _UpperCamelCase (     _a	:	Any				,     _a	:	int				,     _a	:	Dict			):




    """simple docstring"""



    __UpperCamelCase	:	List[Any]		    =  hf_hub_url(repo_id=_a				,     path=_a				,     revision=_a			)
    assert url == f"""https://huggingface.co/datasets/{repo_id}/resolve/{revision or 'main'}/{quote(_a			)}"""



