
"""simple docstring"""





from unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset






class    _UpperCAmelCase(   lowerCamelCase     ):



		def 						UpperCAmelCase							( self)	->	Dict:






							'''simple docstring'''
							return [
							    {"col_1": 3, "col_2": "a"},
							    {"col_1": 2, "col_2": "b"},
							    {"col_1": 1, "col_2": "c"},
							    {"col_1": 0, "col_2": "d"},
							]



		def 						UpperCAmelCase							( self)	->	List[str]:






							'''simple docstring'''
							_UpperCamelCase										=  {'''col_1''': [3, 2, 1, 0], '''col_2''': ['''a''', '''b''', '''c''', '''d''']}
							return Dataset.from_dict(__a)



		def 						UpperCAmelCase							( self)	->	str:






							'''simple docstring'''
							_UpperCamelCase										=  self._create_example_records()
							_UpperCamelCase										=  Dataset.from_list(__a)
							self.assertListEqual(dset.column_names    ,		['''col_1''', '''col_2'''])
							for i, r in enumerate(__a):
												self.assertDictEqual(__a    ,		example_records[i])



		def 						UpperCAmelCase							( self)	->	int:






							'''simple docstring'''
							_UpperCamelCase										=  self._create_example_records()
							_UpperCamelCase										=  Dataset.from_list(__a)
							_UpperCamelCase										=  Dataset.from_dict({k: [r[k] for r in example_records] for k in example_records[0]})
							self.assertEqual(dset.info    ,		dset_from_dict.info)



		def 						UpperCAmelCase							( self)	->	int:  # checks what happens with missing columns






							'''simple docstring'''
							_UpperCamelCase										=  [{'''col_1''': 1}, {'''col_2''': '''x'''}]
							_UpperCamelCase										=  Dataset.from_list(__a)
							self.assertDictEqual(dset[0]    ,		{'''col_1''': 1})
							self.assertDictEqual(dset[1]    ,		{'''col_1''': None})  # NB: first record is used for columns



		def 						UpperCAmelCase							( self)	->	Optional[int]:  # checks if the type can be inferred from the second record






							'''simple docstring'''
							_UpperCamelCase										=  [{'''col_1''': []}, {'''col_1''': [1, 2]}]
							_UpperCamelCase										=  Dataset.from_list(__a)
							self.assertEqual(dset.info.features['''col_1''']    ,		Sequence(Value('''int64''')))




		def 						UpperCAmelCase							( self)	->	List[Any]:






							'''simple docstring'''
							_UpperCamelCase										=  Dataset.from_list([])
							self.assertEqual(len(__a)    ,		0)
							self.assertListEqual(dset.column_names    ,		[])








"""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()






