Merge pull request #3084 from tony-jinwoo-ahn/tan

Add tan() and tanh() for cmath
This commit is contained in:
Jeong YunWon
2021-09-18 21:01:22 +09:00
committed by GitHub
2 changed files with 14 additions and 4 deletions

View File

@@ -56,9 +56,9 @@ class CMathTests(unittest.TestCase):
#
# list of all functions in cmath
test_functions = [getattr(cmath, fname) for fname in [
'sin','cos','log','log10','sqrt','acosh'
'sin','cos','log','log10','sqrt','acosh','tan','tanh'
# 'exp','acos','asin','asinh',
# 'atan','atanh','sinh','cosh','tan','tanh'
# 'atan','atanh','sinh','cosh'
]]
# test first and second arguments independently for 2-argument log
# test_functions.append(lambda x : cmath.log(x, 1729. + 0j))
@@ -590,8 +590,6 @@ class CMathTests(unittest.TestCase):
self.assertTrue(cmath.isinf(complex(NAN, INF)))
self.assertTrue(cmath.isinf(complex(INF, NAN)))
# TODO: RUSTPYTHON
@unittest.expectedFailure
@requires_IEEE_754
def testTanhSign(self):
for z in complex_zeros:

View File

@@ -113,6 +113,18 @@ mod cmath {
z.to_complex().acosh()
}
/// Return the tangent of z.
#[pyfunction]
fn tan(z: IntoPyComplex) -> Complex64 {
z.to_complex().tan()
}
/// Return the hyperbolic tangent of z.
#[pyfunction]
fn tanh(z: IntoPyComplex) -> Complex64 {
z.to_complex().tanh()
}
#[derive(FromArgs)]
struct IsCloseArgs {
#[pyarg(positional)]