MCPcopy Index your code
hub / github.com/python/cpython / testLog

Method testLog

Lib/test/test_math.py:1202–1237  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1200 self.assertEqual(math.ldexp(6993274598585239, -1126), 1e-323)
1201
1202 def testLog(self):
1203 self.assertRaises(TypeError, math.log)
1204 self.assertRaises(TypeError, math.log, 1, 2, 3)
1205 self.ftest('log(1/e)', math.log(1/math.e), -1)
1206 self.ftest('log(1)', math.log(1), 0)
1207 self.ftest('log(e)', math.log(math.e), 1)
1208 self.ftest('log(32,2)', math.log(32,2), 5)
1209 self.ftest('log(10**40, 10)', math.log(10**40, 10), 40)
1210 self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2)
1211 self.ftest('log(10**1000)', math.log(10**1000),
1212 2302.5850929940457)
1213 self.ftest('log(10**2000, 10**1000)', math.log(10**2000, 10**1000), 2)
1214 self.ftest('log(MyIndexable(32), MyIndexable(2))',
1215 math.log(MyIndexable(32), MyIndexable(2)), 5)
1216 self.ftest('log(MyIndexable(10**1000))',
1217 math.log(MyIndexable(10**1000)),
1218 2302.5850929940457)
1219 self.ftest('log(MyIndexable(10**2000), MyIndexable(10**1000))',
1220 math.log(MyIndexable(10**2000), MyIndexable(10**1000)),
1221 2)
1222 self.assertRaises(ValueError, math.log, 0.0)
1223 self.assertRaises(ValueError, math.log, 0)
1224 self.assertRaises(ValueError, math.log, MyIndexable(0))
1225 self.assertRaises(ValueError, math.log, -1.5)
1226 self.assertRaises(ValueError, math.log, -1)
1227 self.assertRaises(ValueError, math.log, MyIndexable(-1))
1228 self.assertRaises(ValueError, math.log, -10**1000)
1229 self.assertRaises(ValueError, math.log, MyIndexable(-10**1000))
1230 self.assertRaises(ValueError, math.log, 10, -10)
1231 self.assertRaises(ValueError, math.log, NINF)
1232 self.assertEqual(math.log(INF), INF)
1233 self.assertTrue(math.isnan(math.log(NAN)))
1234
1235 self.assertEqual(math.log(IndexableFloatLike(math.e, 10**1000)), 1.0)
1236 self.assertAlmostEqual(math.log(IndexableFloatLike(OverflowError(), 10**1000)),
1237 2302.5850929940457)
1238
1239 def testLog1p(self):
1240 self.assertRaises(TypeError, math.log1p)

Callers

nothing calls this directly

Calls 8

ftestMethod · 0.95
IndexableFloatLikeClass · 0.85
assertTrueMethod · 0.80
MyIndexableClass · 0.70
assertRaisesMethod · 0.45
logMethod · 0.45
assertEqualMethod · 0.45
assertAlmostEqualMethod · 0.45

Tested by

no test coverage detected