
"""simple docstring"""

def 							A						(    snake_case				:bytes		)				->     str:
 return "".join([hex(snake_case		)[2:].zfill(2		).upper() for byte in list(snake_case		)]		)






def 							A						(    snake_case				:str		)				->     bytes:
 # Check data validity, following RFC3548
 # https://www.ietf.org/rfc/rfc3548.txt
 if (len(snake_case		) % 2) != 0:
  raise ValueError(
      'Base16 encoded data is invalid:\nData does not have an even number of hex digits.'		)
 # Check the character set - the standard base16 alphabet
 # is uppercase according to RFC3548 section 6
 if not set(snake_case		) <= set('0123456789ABCDEF'		):
  raise ValueError(
      'Base16 encoded data is invalid:\nData is not uppercase hex or it contains invalid characters.'		)
 # For every two hexadecimal digits (= a byte), turn it into an integer.
 # Then, string the result together into bytes, and return it.
 return bytes(int(data[i] + data[i + 1]    , 1_6		) for i in range(0    , len(snake_case		)    , 2		)		)


if __name__ == "__main__":
      import doctest

      doctest.testmod()





"""simple docstring"""

from unittest import TestCase

from datasets import Dataset
from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters






def 							A						(    )				->     Any:
 __UpperCamelCase      =	{
     'repo_name': ['test_repo1', 'test_repo2', 'test_repo3'],
     'path': ['test_1.py', 'test_2.py', 'unit_test.py'],
     'content': ['a ' * 2_0, 'a ' * 3_0, 'b ' * 7],
 }
 __UpperCamelCase      =	Dataset.from_dict(snake_case		)
 return dataset





class __lowerCAmelCase		(				__SCREAMING_SNAKE_CASE      ):





     def 						UpperCAmelCase (     self				):

      '''simple docstring'''




      __UpperCamelCase      =	get_dataset()
      __UpperCamelCase      =	make_duplicate_clusters(__UpperCAmelCase     ,					0.8_5				)
      self.assertEqual(len(duplicate_clusters[0]				)     ,					2				)







     def 						UpperCAmelCase (     self				):

      '''simple docstring'''




      __UpperCamelCase      =	get_dataset()
      __UpperCamelCase  ,     __UpperCamelCase      =	deduplicate_dataset(__UpperCAmelCase				)
      self.assertEqual(len(__UpperCAmelCase				)     ,					2				)
      print(__UpperCAmelCase				)
      self.assertEqual(duplicate_clusters[0][0]['copies']     ,					2				)
      self.assertEqual(duplicate_clusters[0][0]['is_extreme']     ,					__UpperCAmelCase				)



