def test_expand(self): """ Tests the expansion of bounding box. """ box1 = BoundingBox(3, 3, 100, 100) box1.expand() # expand a default of 20% self.assertEqual( box1.get_box(), [-7, -7, 120, 120]) # If you see something weird here,
def test_fit_in_size(self): """ Tests that bounding box is able to adapt itself to specified bounds. """ image_size = [300, 300] # Case1 all out of bounds box1 = BoundingBox(-1, -1, 302, 302) box1.fit_in_size(image_size) self.assertEqual(box1.get_box(), [0, 0, 300, 300]) # Case2 top left out of bounds box1 = BoundingBox(-1, -1, 301, 301) box1.fit_in_size(image_size) self.assertEqual(box1.get_box(), [0, 0, 300, 300]) # Case left out of bounds box1 = BoundingBox(-15, 10, 100, 100) box1.fit_in_size(image_size) self.assertEqual(box1.get_box(), [0, 10, 85, 100]) # Case top out of bounds box1 = BoundingBox(15, -10, 100, 100) box1.fit_in_size(image_size) self.assertEqual(box1.get_box(), [15, 0, 100, 90]) # Case width out of bounds box1 = BoundingBox(15, 0, 290, 100) box1.fit_in_size(image_size) self.assertEqual(box1.get_box(), [15, 0, 285, 100]) # Case height out of bounds box1 = BoundingBox(15, 15, 200, 290) box1.fit_in_size(image_size) self.assertEqual(box1.get_box(), [15, 15, 200, 285])
def test_get_box(self): """ Tests that bounding box successfully returns the array of the box dimensions. """ box = BoundingBox(15, 16, 17, 18) self.assertEqual(box.get_box(), [15, 16, 17, 18])