'''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_337,					num_examples=42,					dataset_name="my_dataset"							)}							),
        SplitDict({"train": SplitInfo(name="train",					num_bytes=1_337,					num_examples=42							)}							),
        SplitDict({"train": SplitInfo()}							),
    ],					)
def    __UpperCAmelCase			(  a_:       SplitDict							):
   _UpperCAmelCase							:	Union[str, Any]							=   split_dict._to_yaml_list()
   assert len(snake_case_							) == len(snake_case_							)
   _UpperCAmelCase							:	Dict							=   SplitDict._from_yaml_list(snake_case_							)
   for split_name, split_info in split_dict.items():
      # dataset_name field is deprecated, and is therefore not part of the YAML dump
      _UpperCAmelCase							:	str							=   None
      # the split name of split_dict takes over the name of the split info object
      _UpperCAmelCase							:	Dict							=   split_name
   assert split_dict == reloaded






@pytest.mark.parametrize(
    "split_info",					[SplitInfo(), SplitInfo(dataset_name=snake_case_							), SplitInfo(dataset_name="my_dataset"							)]							)
def    __UpperCAmelCase			(  a_:       int							):
   # For backward compatibility, we need asdict(split_dict) to return split info dictrionaries with the "dataset_name"
   # field even if it's deprecated. This way old versionso of `datasets` can still reload dataset_infos.json files
   _UpperCAmelCase							:	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






def lowerCamelCase__    (							snake_case_	:  int       )      ->				int:
   if not isinstance(snake_case_       ,      snake_case_       ) or number < 0:
      raise ValueError('''Input must be a non-negative integer'''       )

   __snake_case							       =   0
   while number:
      # This way we arrive at next set bit (next 1) instead of looping
      # through each bit and checking for 1s hence the
      # loop won't run 32 times it will only run the number of `1` times
      number &= number - 1
      count += 1
   return count


if __name__ == "__main__":
    import doctest

    doctest.testmod()

