def test_sort_descending(self): sorted_boxlist = np_box_list_ops.sort_by_field3d(self.boxlist, 'scores') expected_boxes = np.array( [[_degree_to_radians(0.1), 1.0, 4.0, 3.0, 2.0, 7.0, 5.0], [_degree_to_radians(0.2), 14.0, 14.0, 14.0, 15.0, 15.0, 15.0], [_degree_to_radians(0.1), 1.0, 3.0, 4.0, 1.0, 6.0, 8.0], [_degree_to_radians(0.2), 2.0, 5.0, 6.0, 2.0, 10.0, 7.0]], dtype=float) self._compare_boxlist_with_boxes(sorted_boxlist, expected_boxes) expected_scores = np.array([0.9, 0.7, 0.5, 0.4], dtype=float) self.assertAllClose(expected_scores, sorted_boxlist.get_field('scores'))
def test_sort_with_invalid_sorting_order(self): with self.assertRaises(ValueError): np_box_list_ops.sort_by_field3d(self.boxlist, 'scores', 'Descending')
def test_sort_with_invalid_field(self): with self.assertRaises(ValueError): np_box_list_ops.sort_by_field3d(self.boxlist, 'objectness') with self.assertRaises(ValueError): np_box_list_ops.sort_by_field3d(self.boxlist, 'labels')