[change] Quality class determination documentation improvement
Also change order of expected/actual values in test assert methods to improve output of test function. The first parameter is supposed to be the expected value, the second one the actual result.
This commit is contained in:
parent
677d3a200c
commit
146da1d794
@ -1288,6 +1288,7 @@ def get_quality_class(uncertainty, weight_classes):
|
||||
quality = next(i for i, v in enumerate(weight_classes) if v >= uncertainty)
|
||||
except StopIteration:
|
||||
# raised when uncertainty is larger than all values in weight_classes
|
||||
# set quality to max possible value
|
||||
quality = len(weight_classes)
|
||||
return quality
|
||||
|
||||
|
@ -5,6 +5,12 @@ from pylot.core.pick.utils import get_quality_class
|
||||
class TestQualityClassFromUncertainty(unittest.TestCase):
|
||||
"""
|
||||
Test function that assigns a quality value [0...4] to a pick uncertainty.
|
||||
The pick uncertainty is compared to the error classes.
|
||||
A pick uncertainty that is below the first error class is assigned the best quality, quality 0.
|
||||
A pick uncertainty that is above the first error class but below the second is assigned quality 1 and so on.
|
||||
A pick uncertainty that is larger than the biggest error class is assigned quality 4.
|
||||
The upper border of a quality class is inclusive, the lower border exclusive. Meaning if a value is exactly on the
|
||||
border between two classes, it is assigned into the higher quality class (represented by the lower number).
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
@ -14,37 +20,37 @@ class TestQualityClassFromUncertainty(unittest.TestCase):
|
||||
|
||||
def test_out_of_lower_bound(self):
|
||||
# Error out of lower bound of classes
|
||||
self.assertEqual(get_quality_class(0.5, self.error_classes), 0)
|
||||
self.assertEqual(0, get_quality_class(0.5, self.error_classes))
|
||||
|
||||
def test_out_of_upper_bound(self):
|
||||
# Error out of upper bound of error classes
|
||||
self.assertEqual(get_quality_class(14.7, self.error_classes), 4)
|
||||
self.assertEqual(4, get_quality_class(14.7, self.error_classes))
|
||||
|
||||
def test_on_lower_border(self):
|
||||
# Error exactly on lower bound
|
||||
self.assertEqual(get_quality_class(1., self.error_classes), 0)
|
||||
self.assertEqual(0, get_quality_class(1., self.error_classes))
|
||||
|
||||
def test_on_upper_border(self):
|
||||
# Error exactly on upper bound
|
||||
self.assertEqual(get_quality_class(7., self.error_classes), 3)
|
||||
self.assertEqual(3, get_quality_class(7., self.error_classes))
|
||||
|
||||
def test_on_middle_border_inclusive(self):
|
||||
# Error exactly between two classes, since lower bound is exclusive and upper bound is inclusive it should
|
||||
# fall into the class with better quality
|
||||
self.assertEqual(get_quality_class(3., self.error_classes), 1)
|
||||
self.assertNotEqual(get_quality_class(3., self.error_classes), 2)
|
||||
self.assertEqual(1, get_quality_class(3., self.error_classes))
|
||||
self.assertNotEqual(2, get_quality_class(3., self.error_classes))
|
||||
|
||||
def test_in_class0(self):
|
||||
def test_in_class1(self):
|
||||
# Error exactly in class 1
|
||||
self.assertEqual(get_quality_class(1.5, self.error_classes), 1)
|
||||
self.assertEqual(1, get_quality_class(1.5, self.error_classes))
|
||||
|
||||
def test_in_class2(self):
|
||||
# Error exactly in class 2
|
||||
self.assertEqual(get_quality_class(3.5, self.error_classes), 2)
|
||||
self.assertEqual(2, get_quality_class(3.5, self.error_classes))
|
||||
|
||||
def test_in_class3(self):
|
||||
# Error exactly in class 3
|
||||
self.assertEqual(get_quality_class(5.6, self.error_classes), 3)
|
||||
self.assertEqual(3, get_quality_class(5.6, self.error_classes))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user