def test_calculate_multiple_iou_realistic_values(self): box_a = np.array([ [1, 2, 5, 6], ], dtype=np.int) box_b = np.array([ [3, 1, 4, 5], ], dtype=np.int) ious = calculate_multiple_iou(box_a, box_b) self.assertAlmostEqual(ious[0, 0], 8. / 27, delta=1e-6)
def test_calculate_multiple_iou_shape_type_degenerate_zero(self): box_a = np.zeros((3, 4), dtype=np.int) box_b = np.zeros((5, 4), dtype=np.int) ious = calculate_multiple_iou(box_a, box_b) self.assertIsInstance(ious, np.ndarray) self.assertEqual(ious.dtype, np.float) self.assertEqual(ious.shape, (3, 5)) for i in range(ious.shape[0]): for j in range(ious.shape[1]): self.assertEqual(ious[i, j], 1.0)
def test_calculate_multiple_iou_eye_boxes(self): box_a = np.array([ [1, 1, 3, 3], [4, 4, 5, 5], ], dtype=np.int) box_b = np.array([ [1, 1, 3, 3], [4, 4, 5, 5], ], dtype=np.int) ious = calculate_multiple_iou(box_a, box_b) self.assertTrue((ious == np.eye(2)).all())