| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from bisect_results import BisectResults | 8 from bisect_results import BisectResults |
| 9 import source_control | 9 import source_control |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 The score represents our confidence that the two sets of values wouldn't | 81 The score represents our confidence that the two sets of values wouldn't |
| 82 be as different as they are just by chance; that is, that some real change | 82 be as different as they are just by chance; that is, that some real change |
| 83 occurred between the two sets of values. | 83 occurred between the two sets of values. |
| 84 | 84 |
| 85 Args: | 85 Args: |
| 86 score: Expected confidence score. | 86 score: Expected confidence score. |
| 87 bad_values: First list of numbers. | 87 bad_values: First list of numbers. |
| 88 good_values: Second list of numbers. | 88 good_values: Second list of numbers. |
| 89 """ | 89 """ |
| 90 # ConfidenceScore takes a list of lists but these lists are flattened | 90 confidence = BisectResults.ConfidenceScore(bad_values, good_values) |
| 91 # inside the function. | |
| 92 confidence = BisectResults.ConfidenceScore( | |
| 93 [[v] for v in bad_values], | |
| 94 [[v] for v in good_values]) | |
| 95 self.assertEqual(score, confidence) | 91 self.assertEqual(score, confidence) |
| 96 | 92 |
| 97 def testConfidenceScoreIsZeroOnTooFewLists(self): | 93 def testConfidenceScoreIsZeroOnTooFewLists(self): |
| 98 self._AssertConfidence(0.0, [], [[1], [2]]) | 94 self._AssertConfidence(0.0, [], [1, 2]) |
| 99 self._AssertConfidence(0.0, [[1], [2]], []) | 95 self._AssertConfidence(0.0, [1, 2], []) |
| 100 self._AssertConfidence(0.0, [[1]], [[1], [2]]) | 96 self._AssertConfidence(0.0, [1], [1, 2]) |
| 101 self._AssertConfidence(0.0, [[1], [2]], [[1]]) | 97 self._AssertConfidence(0.0, [1, 2], [1]) |
| 102 | |
| 103 def testConfidenceScoreIsZeroOnEmptyLists(self): | |
| 104 self.assertEqual(BisectResults.ConfidenceScore([[], []], [[1], [2]]), 0.0) | |
| 105 self.assertEqual(BisectResults.ConfidenceScore([[1], [2]], [[], []]), 0.0) | |
| 106 | 98 |
| 107 def testConfidenceScore_ZeroConfidence(self): | 99 def testConfidenceScore_ZeroConfidence(self): |
| 108 # The good and bad sets contain the same values, so the confidence that | 100 # The good and bad sets contain the same values, so the confidence that |
| 109 # they're different should be zero. | 101 # they're different should be zero. |
| 110 self._AssertConfidence(0.0, [4, 5, 7, 6, 8, 7], [8, 7, 6, 7, 5, 4]) | 102 self._AssertConfidence(0.0, [4, 5, 7, 6, 8, 7], [8, 7, 6, 7, 5, 4]) |
| 111 | 103 |
| 112 def testConfidenceScore_MediumConfidence(self): | 104 def testConfidenceScore_MediumConfidence(self): |
| 113 self._AssertConfidence(80.0, [0, 1, 1, 1, 2, 2], [1, 1, 1, 3, 3, 4]) | 105 self._AssertConfidence(80.0, [0, 1, 1, 1, 2, 2], [1, 1, 1, 3, 3, 4]) |
| 114 | 106 |
| 115 def testConfidenceScore_HighConfidence(self): | 107 def testConfidenceScore_HighConfidence(self): |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 revision_states[3].value = {'values': [100, 105, 95]} | 241 revision_states[3].value = {'values': [100, 105, 95]} |
| 250 revision_states[4].value = {'values': [100, 105, 95]} | 242 revision_states[4].value = {'values': [100, 105, 95]} |
| 251 results = BisectResults(self.mock_bisect_state, self.mock_depot_registry, | 243 results = BisectResults(self.mock_bisect_state, self.mock_depot_registry, |
| 252 self.mock_opts, self.mock_warnings) | 244 self.mock_opts, self.mock_warnings) |
| 253 self.assertEqual(0, results.confidence) | 245 self.assertEqual(0, results.confidence) |
| 254 self.assertEqual(1, len(results.warnings)) | 246 self.assertEqual(1, len(results.warnings)) |
| 255 | 247 |
| 256 | 248 |
| 257 if __name__ == '__main__': | 249 if __name__ == '__main__': |
| 258 unittest.main() | 250 unittest.main() |
| OLD | NEW |