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 """Unit tests for ttest module.""" | 5 """Unit tests for ttest module.""" |
6 | 6 |
7 import unittest | 7 import unittest |
8 | 8 |
9 import ttest | 9 import ttest |
10 | 10 |
11 | 11 |
| 12 # This test case accesses private functions of the ttest module. |
| 13 # pylint: disable=W0212 |
12 class TTestTest(unittest.TestCase): | 14 class TTestTest(unittest.TestCase): |
13 """Tests for the t-test functions.""" | 15 """Tests for the t-test functions.""" |
14 | 16 |
15 def testWelchsFormula(self): | 17 def testWelchsFormula(self): |
16 """Tests calculation of the t value.""" | 18 """Tests calculation of the t value.""" |
17 # Results can be verified by directly plugging variables into Welch's | 19 # Results can be verified by directly plugging variables into Welch's |
18 # equation (e.g. using a calculator or the Python interpreter). | 20 # equation (e.g. using a calculator or the Python interpreter). |
19 self.assertEqual( | 21 self.assertEqual( |
20 -0.2796823595120407, | 22 -0.2796823595120407, |
21 ttest._TValue(0.299, 0.307, 0.05, 0.08, 150, 165)) | 23 ttest._TValue(0.299, 0.307, 0.05, 0.08, 150, 165)) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 self.assertEqual(1, ttest._LookupPValue(0.0, 1)) | 115 self.assertEqual(1, ttest._LookupPValue(0.0, 1)) |
114 self.assertEqual(1, ttest._LookupPValue(0.0, 2)) | 116 self.assertEqual(1, ttest._LookupPValue(0.0, 2)) |
115 | 117 |
116 def testLookupLargeDF(self): | 118 def testLookupLargeDF(self): |
117 """Tests a lookup when the given degrees of freedom is large.""" | 119 """Tests a lookup when the given degrees of freedom is large.""" |
118 self.assertEqual(0.02, ttest._LookupPValue(5.0, 50)) | 120 self.assertEqual(0.02, ttest._LookupPValue(5.0, 50)) |
119 | 121 |
120 | 122 |
121 if __name__ == '__main__': | 123 if __name__ == '__main__': |
122 unittest.main() | 124 unittest.main() |
OLD | NEW |