


"""simple docstring"""







import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey






class 						_A  :







    """simple docstring"""




    def __init__(					self				:    Optional[Any]				, __UpperCAmelCase				:    Optional[Any]				, __UpperCAmelCase				:    int				, __UpperCAmelCase				:    int):
      if dst_width < 0 or dst_height < 0:
        raise ValueError("Destination width/height should be > 0")

      a						:		Union[str, Any]      							=			img
      a						:		Optional[int]      							=			img.shape[1]
      a						:		Dict      							=			img.shape[0]
      a						:		Dict      							=			dst_width
      a						:		Any      							=			dst_height

      a						:		str      							=			self.src_w / self.dst_w
      a						:		Dict      							=			self.src_h / self.dst_h

      a						:		Dict      							=			(
          np.ones((self.dst_h, self.dst_w, 3)				, np.uinta) * 255
      )






    def 	__snake_case							(					self				:    Tuple):
      for i in range(self.dst_h):
        for j in range(self.dst_w):
          a						:		List[str]      							=			self.img[self.get_y(__UpperCAmelCase)][self.get_x(__UpperCAmelCase)]






    def 	__snake_case							(					self				:    Dict				, __UpperCAmelCase				:    int):
      return int(self.ratio_x * x)






    def 	__snake_case							(					self				:    Optional[int]				, __UpperCAmelCase				:    int):
      return int(self.ratio_y * y)


if __name__ == "__main__":
 __lowercase					,							__lowercase    					=      800, 600
 __lowercase    					=      imread("""image_data/lena.jpg""", 1)
 __lowercase    					=      NearestNeighbour(im, dst_w, dst_h)
 n.process()

 imshow(
     f'''Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}''', n.output
 )
 waitKey(0)
 destroyAllWindows()









'''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     (    ):






 """simple docstring"""



 with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT      ):
  with pytest.raises(A__      ):
   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     (    ):






 """simple docstring"""



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






def 		_A     (    ):






 """simple docstring"""



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

