


'''simple docstring'''






import pytest
import requests

from datasets.utils.file_utils import http_head

from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline






@pytest.mark.integration
def 		_A			()				->					Optional[Any]:




     '''simple docstring'''



     with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT						):
          with pytest.raises(lowerCAmelCase__						):
               requests.request('GET'			,  'https://huggingface.co'						)
          with pytest.raises(requests.exceptions.ConnectTimeout						):
               requests.request('GET'			,  'https://huggingface.co'			,  timeout=1.0						)






@pytest.mark.integration
def 		_A			()				->					Any:




     '''simple docstring'''



     with offline(OfflineSimulationMode.CONNECTION_FAILS						):
          with pytest.raises(requests.exceptions.ConnectionError						):
               requests.request('GET'			,  'https://huggingface.co'						)






def 		_A			()				->					Dict:




     '''simple docstring'''



     with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1						):
          with pytest.raises(lowerCAmelCase__						):
               http_head('https://huggingface.co'						)





'''simple docstring'''






from timeit import timeit






def 		_A			(lowerCAmelCase__					:int						)				->					int:




     '''simple docstring'''



     if number < 0:
          raise ValueError('the value of input must not be negative'						)
     _a      =							0
     while number:
          number &= number - 1
          result += 1
     return result






def 		_A			(lowerCAmelCase__					:int						)				->					int:




     '''simple docstring'''



     if number < 0:
          raise ValueError('the value of input must not be negative'						)
     _a      =							0
     while number:
          if number % 2 == 1:
               result += 1
          number >>= 1
     return result






def 		_A			()				->					None:




     '''simple docstring'''



     def do_benchmark(lowerCAmelCase__					:int						) -> None:
          _a      =							'import __main__ as z'
          print(f'Benchmark when {number = }:'						)
          print(f'{get_set_bits_count_using_modulo_operator(lowerCAmelCase__						) = }'						)
          _a      =							timeit('z.get_set_bits_count_using_modulo_operator(25)'			,  setup=lowerCAmelCase__						)
          print(f'timeit() runs in {timing} seconds'						)
          print(f'{get_set_bits_count_using_brian_kernighans_algorithm(lowerCAmelCase__						) = }'						)
          _a      =							timeit(
              'z.get_set_bits_count_using_brian_kernighans_algorithm(25)'			,  setup=lowerCAmelCase__			,  )
          print(f'timeit() runs in {timing} seconds'						)

     for number in (25, 37, 58, 0):
          do_benchmark(lowerCAmelCase__						)
          print()


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 benchmark()

