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

Method testApproximatePi

Lib/test/test_fractions.py:1158–1169  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1156 self.assertEqual(hash(F(-1)), F(-1).__hash__())
1157
1158 def testApproximatePi(self):
1159 # Algorithm borrowed from
1160 # http://docs.python.org/lib/decimal-recipes.html
1161 three = F(3)
1162 lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24
1163 while abs(s - lasts) > F(1, 10**9):
1164 lasts = s
1165 n, na = n+na, na+8
1166 d, da = d+da, da+32
1167 t = (t * n) / d
1168 s += t
1169 self.assertAlmostEqual(math.pi, s)
1170
1171 def testApproximateCos1(self):
1172 # Algorithm borrowed from

Callers

nothing calls this directly

Calls 3

absFunction · 0.85
FClass · 0.70
assertAlmostEqualMethod · 0.45

Tested by

no test coverage detected