| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 unittest | 5 import unittest |
| 6 | 6 |
| 7 from dashboard.pinpoint import mann_whitney_u | 7 from dashboard.pinpoint.models import mann_whitney_u |
| 8 | 8 |
| 9 | 9 |
| 10 class MannWhitneyUTest(unittest.TestCase): | 10 class MannWhitneyUTest(unittest.TestCase): |
| 11 def testBasic(self): | 11 def testBasic(self): |
| 12 self.assertAlmostEqual( | 12 self.assertAlmostEqual( |
| 13 mann_whitney_u.MannWhitneyU(range(10), range(20, 30)), | 13 mann_whitney_u.MannWhitneyU(range(10), range(20, 30)), |
| 14 0.00018267179110955002) | 14 0.00018267179110955002) |
| 15 self.assertAlmostEqual( | 15 self.assertAlmostEqual( |
| 16 mann_whitney_u.MannWhitneyU(range(5), range(10)), | 16 mann_whitney_u.MannWhitneyU(range(5), range(10)), |
| 17 0.13986357686781267) | 17 0.13986357686781267) |
| 18 | 18 |
| 19 def testDuplicateValues(self): | 19 def testDuplicateValues(self): |
| 20 self.assertAlmostEqual(mann_whitney_u.MannWhitneyU([0] * 5, [1] * 5), | 20 self.assertAlmostEqual(mann_whitney_u.MannWhitneyU([0] * 5, [1] * 5), |
| 21 0.0039767517097886512) | 21 0.0039767517097886512) |
| 22 | 22 |
| 23 def testSmallSamples(self): | 23 def testSmallSamples(self): |
| 24 self.assertEqual(mann_whitney_u.MannWhitneyU([0], [1]), 1.0) | 24 self.assertEqual(mann_whitney_u.MannWhitneyU([0], [1]), 1.0) |
| 25 | 25 |
| 26 def testAllValuesIdentical(self): | 26 def testAllValuesIdentical(self): |
| 27 with self.assertRaises(ValueError): | 27 with self.assertRaises(ValueError): |
| 28 mann_whitney_u.MannWhitneyU([0] * 5, [0] * 5) | 28 mann_whitney_u.MannWhitneyU([0] * 5, [0] * 5) |
| 29 | 29 |
| 30 | 30 |
| 31 if __name__ == '__main__': | 31 if __name__ == '__main__': |
| 32 unittest.main() | 32 unittest.main() |
| OLD | NEW |