diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-09-29 19:06:36 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-09-29 19:06:36 (GMT) |
commit | c60371748b400b8b891fb2e5d2fe25b007c85994 (patch) | |
tree | c35b85a1e9f1cfd904e0c655e739e116c530f866 /Lib/test | |
parent | 0c0714f954bd78fdeae30ae284abc381bd850393 (diff) | |
download | cpython-c60371748b400b8b891fb2e5d2fe25b007c85994.zip cpython-c60371748b400b8b891fb2e5d2fe25b007c85994.tar.gz cpython-c60371748b400b8b891fb2e5d2fe25b007c85994.tar.bz2 |
Issue #9599: Further accuracy tweaks to loghelper. For an integer n that's small enough to be converted to a float without overflow, log(n) is now computed as log(float(n)), and similarly for log10.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_math.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 90bd363..1499ff9 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -641,8 +641,12 @@ class MathTests(unittest.TestCase): self.ftest('log(32,2)', math.log(32,2), 5) self.ftest('log(10**40, 10)', math.log(10**40, 10), 40) self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2) - self.assertEquals(math.log(INF), INF) + self.ftest('log(10**1000)', math.log(10**1000), + 2302.5850929940457) + self.assertRaises(ValueError, math.log, -1.5) + self.assertRaises(ValueError, math.log, -10**1000) self.assertRaises(ValueError, math.log, NINF) + self.assertEquals(math.log(INF), INF) self.assertTrue(math.isnan(math.log(NAN))) def testLog1p(self): @@ -655,8 +659,11 @@ class MathTests(unittest.TestCase): self.ftest('log10(0.1)', math.log10(0.1), -1) self.ftest('log10(1)', math.log10(1), 0) self.ftest('log10(10)', math.log10(10), 1) - self.assertEquals(math.log(INF), INF) + self.ftest('log10(10**1000)', math.log10(10**1000), 1000.0) + self.assertRaises(ValueError, math.log10, -1.5) + self.assertRaises(ValueError, math.log10, -10**1000) self.assertRaises(ValueError, math.log10, NINF) + self.assertEquals(math.log(INF), INF) self.assertTrue(math.isnan(math.log10(NAN))) def testModf(self): |