"""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=1337   , num_examples=42   , dataset_name='my_dataset'     )}     ),
        SplitDict({'train': SplitInfo(name='train'   , num_bytes=1337   , num_examples=42     )}     ),
        SplitDict({'train': SplitInfo()}     ),
    ]   , )
def 				a_     (      _lowerCAmelCase  : SplitDict     ):





       '''simple docstring'''

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






@pytest.mark.parametrize(
    'split_info'   , [SplitInfo(), SplitInfo(dataset_name=_lowerCamelCase     ), SplitInfo(dataset_name='my_dataset'     )]     )
def 				a_     (      _lowerCAmelCase  : List[str]     ):





       '''simple docstring'''

       lowercase__			:		Optional[Any]       =	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 __future__ import annotations


def 				lowerCAmelCase_   (	_lowerCamelCase:   list[int]       ,      _lowerCamelCase:   list[int]       ,      _lowerCamelCase:   int					):
		__SCREAMING_SNAKE_CASE       :		List[Any]           =		list(range(len(_lowerCamelCase					)					)					)
		__SCREAMING_SNAKE_CASE       :		Optional[Any]           =		[v / w for v, w in zip(_lowerCamelCase       ,      _lowerCamelCase					)]
		index.sort(key=lambda _lowerCamelCase					: ratio[i]       ,      reverse=_lowerCamelCase					)

		__SCREAMING_SNAKE_CASE       :		float           =		0
		__SCREAMING_SNAKE_CASE       :		list[float]           =		[0] * len(_lowerCamelCase					)
		for i in index:
				if weight[i] <= capacity:
						__SCREAMING_SNAKE_CASE       :		str           =		1
						max_value += value[i]
						capacity -= weight[i]
				else:
						__SCREAMING_SNAKE_CASE       :		int           =		capacity / weight[i]
						max_value += value[i] * capacity / weight[i]
						break

		return max_value, fractions


if __name__ == "__main__":
						import doctest

						doctest.testmod()