diff --git a/analysis/tests/utility_analysis_test.py b/analysis/tests/utility_analysis_test.py index 8035fe21..3bd9951b 100644 --- a/analysis/tests/utility_analysis_test.py +++ b/analysis/tests/utility_analysis_test.py @@ -292,7 +292,7 @@ def test_multi_parameters(self): expected_l0_error[i_configuration]) def test_generate_bucket_bounds(self): - self.assertLen(utility_analysis._generate_bucket_bounds(), 29) + self.assertLen(utility_analysis._generate_bucket_bounds(), 38) self.assertEqual(utility_analysis._generate_bucket_bounds()[:10], (0, 1, 10, 20, 50, 100, 200, 500, 1000, 2000)) @@ -304,6 +304,7 @@ def test_get_lower_bound(self): self.assertEqual(utility_analysis._get_lower_bound(11), 10) self.assertEqual(utility_analysis._get_lower_bound(20), 20) self.assertEqual(utility_analysis._get_lower_bound(1234), 1000) + self.assertEqual(utility_analysis._get_upper_bound(10**13), -1) def test_get_upper_bound(self): self.assertEqual(utility_analysis._get_upper_bound(-1), 0) @@ -313,6 +314,7 @@ def test_get_upper_bound(self): self.assertEqual(utility_analysis._get_upper_bound(11), 20) self.assertEqual(utility_analysis._get_upper_bound(20), 50) self.assertEqual(utility_analysis._get_upper_bound(1234), 2000) + self.assertEqual(utility_analysis._get_upper_bound(10**13), -1) def test_unnest_metrics(self): input_data = self._get_per_partition_metrics(n_configurations=2) diff --git a/analysis/utility_analysis.py b/analysis/utility_analysis.py index 198b7df9..ee5a70dd 100644 --- a/analysis/utility_analysis.py +++ b/analysis/utility_analysis.py @@ -27,15 +27,15 @@ def _generate_bucket_bounds(): result = [0, 1] - for i in range(1, 10): + for i in range(1, 13): result.append(10**i) result.append(2 * 10**i) result.append(5 * 10**i) return tuple(result) -# Bucket bounds for metrics. UtilityReportHistogram. -# Bounds are logarithmic: [0, 1] + [1, 2, 5]*10**i , for i = 1, 10. +# Bucket bounds for metrics. UtilityReport histogram. +# Bounds are logarithmic: [0, 1] + [1, 2, 5]*10**i , for i = 1, 12 BUCKET_BOUNDS = _generate_bucket_bounds() @@ -188,8 +188,8 @@ def _get_upper_bound(n: int) -> int: if n < 0: return 0 index = bisect.bisect_right(BUCKET_BOUNDS, n) - if index > len(BUCKET_BOUNDS): - return -1 # todo + if index >= len(BUCKET_BOUNDS): + return -1 return BUCKET_BOUNDS[index] @@ -216,7 +216,7 @@ def _group_utility_reports( 'reports' contains the global report, i.e. which corresponds to all partitions and reports that corresponds to partitions of some size range. - This function creates UtilityReportHistogram from reports by size range and + This function creates UtilityReport histogram from reports by size range and sets it to the global report. """ global_report = None