



"""simple docstring"""






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



class     UpperCAmelCase    :



   def __init__(       self    :	str							,       __lowerCamelCase    :	Union[str, Any]							,       __lowerCamelCase    :	int							,       __lowerCamelCase    :	int				):



     """simple docstring"""
     if dst_width < 0 or dst_height < 0:
       raise ValueError('''Destination width/height should be > 0'''				)

     _snake_case   	=      img
     _snake_case   	=      img.shape[1]
     _snake_case   	=      img.shape[0]
     _snake_case   	=      dst_width
     _snake_case   	=      dst_height

     _snake_case   	=      self.src_w / self.dst_w
     _snake_case   	=      self.src_h / self.dst_h

     _snake_case   	=      _snake_case   	=      (
         np.ones((self.dst_h, self.dst_w, 3)							,       np.uinta				) * 2_5_5
     )



   def    __UpperCAmelCase    (       self    :	Optional[int]				):



     """simple docstring"""
     for i in range(self.dst_h				):
       for j in range(self.dst_w				):
         _snake_case   	=      self.img[self.get_y(__lowerCamelCase				)][self.get_x(__lowerCamelCase				)]



   def    __UpperCAmelCase    (       self    :	Union[str, Any]							,       __lowerCamelCase    :	int				):



     """simple docstring"""
     return int(self.ratio_x * x				)





   def    __UpperCAmelCase    (       self    :	List[Any]							,       __lowerCamelCase    :	int				):



     """simple docstring"""
     return int(self.ratio_y * y				)


if __name__ == "__main__":
     snake_case					,  snake_case   					=				8_0_0, 6_0_0
     snake_case   					=				imread('''image_data/lena.jpg''', 1)
     snake_case   					=				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 operator




def 			snake_case		(		lowerCAmelCase_  ,						lowerCAmelCase_ = False  ,						lowerCAmelCase_ = None	)						->				list:
  _snake_case   	=      operator.lt if reverse else operator.gt
  _snake_case   	=      solution or []

  if not arr:
    return solution

  _snake_case   	=      [arr.pop(0	)]
  for i, item in enumerate(lowerCAmelCase_	):
    if _operator(lowerCAmelCase_  ,						sublist[-1]	):
      sublist.append(lowerCAmelCase_	)
      arr.pop(lowerCAmelCase_	)

    #  merging sublist into solution list
  if not solution:
    solution.extend(lowerCAmelCase_	)
  else:
    while sublist:
      _snake_case   	=      sublist.pop(0	)
      for i, xx in enumerate(lowerCAmelCase_	):
        if not _operator(lowerCAmelCase_  ,						lowerCAmelCase_	):
          solution.insert(lowerCAmelCase_  ,						lowerCAmelCase_	)
          break
      else:
        solution.append(lowerCAmelCase_	)

  strand_sort(lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_	)
  return solution


if __name__ == "__main__":
     assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
     assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]





