
"""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=13_37,					num_examples=42,					dataset_name='''my_dataset'''     )}     ),
        SplitDict({'''train''': SplitInfo(name='''train''',					num_bytes=13_37,					num_examples=42     )}     ),
        SplitDict({'''train''': SplitInfo()}     ),
    ],					)
def 				lowerCamelCase__		(      __snake_case     )							->		int:


					"""simple docstring"""





					_UpperCamelCase										=  split_dict._to_yaml_list()
					assert len(__snake_case     ) == len(__snake_case     )
					_UpperCamelCase										=  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										=  None
										# the split name of split_dict takes over the name of the split info object
										_UpperCamelCase										=  split_name
					assert split_dict == reloaded



@pytest.mark.parametrize(
    '''split_info''',					[SplitInfo(), SplitInfo(dataset_name=__snake_case     ), SplitInfo(dataset_name='''my_dataset'''     )]     )
def 				lowerCamelCase__		(      __snake_case     )							->		Union[str, Any]:


					"""simple docstring"""





					_UpperCamelCase										=  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"""





def 				lowerCamelCase__		(      __snake_case,					__snake_case     )							->		str:


					"""simple docstring"""





					if number < 0 or shift_amount < 0:
										raise ValueError('''both inputs must be positive integers'''     )

					_UpperCamelCase										=  str(bin(__snake_case     )     )
					binary_number += "0" * shift_amount
					return binary_number



def 				lowerCamelCase__		(      __snake_case,					__snake_case     )							->		str:


					"""simple docstring"""





					if number < 0 or shift_amount < 0:
										raise ValueError('''both inputs must be positive integers'''     )

					_UpperCamelCase										=  str(bin(__snake_case     )     )[2:]
					if shift_amount >= len(__snake_case     ):
										return "0b0"
					_UpperCamelCase										=  binary_number[: len(__snake_case     ) - shift_amount]
					return "0b" + shifted_binary_number



def 				lowerCamelCase__		(      __snake_case,					__snake_case     )							->		str:


					"""simple docstring"""





					if number >= 0:  # Get binary representation of positive number
										_UpperCamelCase										=  '''0''' + str(bin(__snake_case     )     ).strip('''-'''     )[2:]
					else:  # Get binary (2's complement) representation of negative number
										_UpperCamelCase										=  len(bin(__snake_case     )[3:]     )  # Find 2's complement of number
										_UpperCamelCase										=  bin(abs(__snake_case     ) - (1 << binary_number_length)     )[3:]
										_UpperCamelCase										=  (
										    '''1''' + '''0''' * (binary_number_length - len(__snake_case     )) + binary_number
										)

					if shift_amount >= len(__snake_case     ):
										return "0b" + binary_number[0] * len(__snake_case     )
					return (
					    "0b"
					    + binary_number[0] * shift_amount
					    + binary_number[: len(__snake_case     ) - shift_amount]
					)


if __name__ == "__main__":
				import doctest

				doctest.testmod()






