|
Packit |
562c7a |
# mode: run
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
from libc.math cimport (M_E, M_LOG2E, M_LOG10E, M_LN2, M_LN10, M_PI, M_PI_2,
|
|
Packit |
562c7a |
M_PI_4, M_1_PI, M_2_PI, M_2_SQRTPI, M_SQRT2, M_SQRT1_2)
|
|
Packit |
562c7a |
from libc.math cimport (acos, asin, atan, atan2, cos, sin, tan, cosh, sinh,
|
|
Packit |
562c7a |
tanh, acosh, asinh, atanh, exp, log, log10, pow, sqrt)
|
|
Packit |
562c7a |
cimport libc.math as libc_math
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
def test_pi():
|
|
Packit |
562c7a |
"""
|
|
Packit |
562c7a |
>>> import math
|
|
Packit |
562c7a |
>>> test_pi() == math.pi
|
|
Packit |
562c7a |
True
|
|
Packit |
562c7a |
"""
|
|
Packit |
562c7a |
return M_PI
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
def test_renamed_constants(math):
|
|
Packit |
562c7a |
"""
|
|
Packit |
562c7a |
>>> import math
|
|
Packit |
562c7a |
>>> test_renamed_constants(math)
|
|
Packit |
562c7a |
"""
|
|
Packit |
562c7a |
assert libc_math.M_E == libc_math.e == math.e
|
|
Packit |
562c7a |
assert libc_math.M_PI == libc_math.pi == math.pi
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
|
|
Packit |
562c7a |
def test_sin(x):
|
|
Packit |
562c7a |
"""
|
|
Packit |
562c7a |
>>> test_sin(0)
|
|
Packit |
562c7a |
0.0
|
|
Packit |
562c7a |
>>> from math import sin
|
|
Packit |
562c7a |
>>> [sin(k) == test_sin(k) for k in range(10)]
|
|
Packit |
562c7a |
[True, True, True, True, True, True, True, True, True, True]
|
|
Packit |
562c7a |
"""
|
|
Packit |
562c7a |
return sin(x)
|