


'''simple docstring'''



import unittest

from knapsack import knapsack as k





class    UpperCAmelCase_  (unittest.TestCase  ):





    """simple docstring"""






    def       lowercase_				(							self	)				->     Optional[Any]:
         __lowerCamelCase   :	int								=		0
         __lowerCamelCase   :	Union[str, Any]								=		[0]
         __lowerCamelCase   :	Any								=		[0]
         __lowerCamelCase   :	Union[str, Any]								=		len(SCREAMING_SNAKE_CASE_	)
         self.assertEqual(k.knapsack(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)			,     0	)

         __lowerCamelCase   :	List[str]								=		[60]
         __lowerCamelCase   :	Union[str, Any]								=		[10]
         __lowerCamelCase   :	List[Any]								=		len(SCREAMING_SNAKE_CASE_	)
         self.assertEqual(k.knapsack(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)			,     0	)







    def       lowercase_				(							self	)				->     List[str]:
         __lowerCamelCase   :	Optional[int]								=		3
         __lowerCamelCase   :	int								=		[1, 2, 3]
         __lowerCamelCase   :	str								=		[3, 2, 1]
         __lowerCamelCase   :	Union[str, Any]								=		len(SCREAMING_SNAKE_CASE_	)
         self.assertEqual(k.knapsack(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)			,     5	)







    def       lowercase_				(							self	)				->     int:
         __lowerCamelCase   :	Optional[int]								=		50
         __lowerCamelCase   :	List[str]								=		[60, 1_00, 1_20]
         __lowerCamelCase   :	List[str]								=		[10, 20, 30]
         __lowerCamelCase   :	List[str]								=		len(SCREAMING_SNAKE_CASE_	)
         self.assertEqual(k.knapsack(SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)			,     2_20	)


if __name__ == "__main__":
      unittest.main()










'''simple docstring'''



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





class    UpperCAmelCase_  :





    """simple docstring"""






    def __init__(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     int:
         if dst_width < 0 or dst_height < 0:
              raise ValueError('Destination width/height should be > 0'	)

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

         __lowerCamelCase   :	Dict								=		self.src_w / self.dst_w
         __lowerCamelCase   :	List[Any]								=		self.src_h / self.dst_h

         __lowerCamelCase   :	Optional[int]								=		(
             np.ones((self.dst_h, self.dst_w, 3)			,     np.uinta	) * 2_55
         )







    def       lowercase_				(							self	)				->     List[Any]:
         for i in range(self.dst_h	):
              for j in range(self.dst_w	):
                   __lowerCamelCase   :	Union[str, Any]								=		self.img[self.get_y(SCREAMING_SNAKE_CASE_	)][self.get_x(SCREAMING_SNAKE_CASE_	)]







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_	)				->     int:
         return int(self.ratio_x * x	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_	)				->     int:
         return int(self.ratio_y * y	)


if __name__ == "__main__":
      A__						,					A__		:					Optional[Any]												=  800, 600
      A__		:					List[str]												=  imread("""image_data/lena.jpg""", 1)
      A__		:					List[Any]												=  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()






