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

Method testApproximateCos1

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

Source from the content-addressed store, hash-verified

1169 self.assertAlmostEqual(math.pi, s)
1170
1171 def testApproximateCos1(self):
1172 # Algorithm borrowed from
1173 # http://docs.python.org/lib/decimal-recipes.html
1174 x = F(1)
1175 i, lasts, s, fact, num, sign = 0, 0, F(1), 1, 1, 1
1176 while abs(s - lasts) > F(1, 10**9):
1177 lasts = s
1178 i += 2
1179 fact *= i * (i-1)
1180 num *= x * x
1181 sign *= -1
1182 s += num / fact * sign
1183 self.assertAlmostEqual(math.cos(1), s)
1184
1185 def test_copy_deepcopy_pickle(self):
1186 r = F(13, 7)

Callers

nothing calls this directly

Calls 3

absFunction · 0.85
FClass · 0.70
assertAlmostEqualMethod · 0.45

Tested by

no test coverage detected