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





"""simple docstring"""

def 							A						(    snake_case				:int		)				->     int:
 __UpperCamelCase      =	abs(snake_case		)
 __UpperCamelCase      =	0
 while n > 0:
  res += n % 1_0
  n //= 1_0
 return res






def 							A						(    snake_case				:int		)				->     int:
 __UpperCamelCase      =	abs(snake_case		)
 return n if n < 1_0 else n % 1_0 + sum_of_digits(n // 1_0		)






def 							A						(    snake_case				:int		)				->     int:
 return sum(int(snake_case		) for c in str(abs(snake_case		)		)		)






def 							A						(    )				->     None:
 from collections.abc import Callable
 from timeit import timeit

 def benchmark_a_function(snake_case				:Callable    , snake_case				:int		) -> None:
  __UpperCamelCase      =	f'{func.__name__}({value})'
  __UpperCamelCase      =	timeit(f'__main__.{call}'    , setup='import __main__'		)
  print(f'{call:56} = {func(snake_case		)} -- {timing:.4f} seconds'		)

 for value in (2_6_2_1_4_4, 1_1_2_5_8_9_9_9_0_6_8_4_2_6_2_4, 1_2_6_7_6_5_0_6_0_0_2_2_8_2_2_9_4_0_1_4_9_6_7_0_3_2_0_5_3_7_6):
  for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
   benchmark_a_function(snake_case    , snake_case		)
  print()


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      benchmark()



