Esempio n. 1
0
 def test_errors_if_covar_is_not_postitive_definite(self):
     cov1 = [[1, 4], [4, 1]]
     cov2 = [[3, 1], [1, 4]]
     with self.assertRaises(ValueError):
         submission_builder.make_detection([0.1, 0.2, 0.3, 0.4, 0.5], 1, 3, 12, 14,
                                           upper_left_cov=cov1, lower_right_cov=cov2)
     with self.assertRaises(ValueError):
         submission_builder.make_detection([0.1, 0.2, 0.3, 0.4, 0.5], 1, 3, 12, 14,
                                           upper_left_cov=cov2, lower_right_cov=cov1)
Esempio n. 2
0
 def test_makes_valid_detection_without_covars(self):
     confidences = [0.1, 0.2, 0.3, 0.4]
     det = submission_builder.make_detection(confidences, 1, 3, 12, 14)
     self.assertIn('bbox', det)
     self.assertIn('label_probs', det)
     self.assertNotIn('covars', det)
     self.assertEqual([1, 3, 12, 14], det['bbox'])
     self.assertEqual(confidences, det['label_probs'])
Esempio n. 3
0
 def test_makes_valid_detection_with_covars(self):
     confidences = [0.1, 0.2, 0.3, 0.4]
     upper_left = [[3, 1], [1, 4]]
     lower_right = [[10, 0], [0, 15]]
     det = submission_builder.make_detection(confidences, 1, 3, 12, 14, upper_left, lower_right)
     self.assertIn('bbox', det)
     self.assertIn('label_probs', det)
     self.assertIn('covars', det)
     self.assertEqual([1, 3, 12, 14], det['bbox'])
     self.assertEqual(confidences, det['label_probs'])
     self.assertEqual([upper_left, lower_right], det['covars'])
Esempio n. 4
0
 def test_errors_if_only_one_covar_given(self):
     cov = [[3, 1], [1, 4]]
     with self.assertRaises(ValueError):
         submission_builder.make_detection([0.1, 0.2, 0.3, 0.4, 0.5], 1, 3, 12, 14, upper_left_cov=cov)
     with self.assertRaises(ValueError):
         submission_builder.make_detection([0.1, 0.2, 0.3, 0.4, 0.5], 1, 3, 12, 14, lower_right_cov=cov)
Esempio n. 5
0
 def test_normalizes_probabilities_greater_than_1(self):
     probs = [0.1, 0.2, 0.3, 0.4, 0.5]
     total_prob = sum(probs)
     normalized_probs = [v / total_prob for v in probs]
     detection = submission_builder.make_detection(probs, 1, 3, 12, 14)
     self.assertEqual(detection['label_probs'], normalized_probs)
Esempio n. 6
0
 def test_errors_if_ymax_less_than_ymin(self):
     with self.assertRaises(ValueError) as cm:
         submission_builder.make_detection([0.1, 0.2, 0.3, 0.4], 1, 31, 12, 14)
     msg = str(cm.exception)
     self.assertIn('ymax', msg)
     self.assertIn('ymin', msg)