MCPcopy Create free account
hub / github.com/numpy/numpy / test_against_cmath

Method test_against_cmath

numpy/core/tests/test_umath.py:4179–4199  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4177 _check_branch_cut(np.arctanh, [0-2j, 2j, 0], [1, 1, 1j], 1, 1, False, np.complex64)
4178
4179 def test_against_cmath(self):
4180 import cmath
4181
4182 points = [-1-1j, -1+1j, +1-1j, +1+1j]
4183 name_map = {'arcsin': 'asin', 'arccos': 'acos', 'arctan': 'atan',
4184 'arcsinh': 'asinh', 'arccosh': 'acosh', 'arctanh': 'atanh'}
4185 atol = 4*np.finfo(complex).eps
4186 for func in self.funcs:
4187 fname = func.__name__.split('.')[-1]
4188 cname = name_map.get(fname, fname)
4189 try:
4190 cfunc = getattr(cmath, cname)
4191 except AttributeError:
4192 continue
4193 for p in points:
4194 a = complex(func(np.complex_(p)))
4195 b = cfunc(p)
4196 assert_(
4197 abs(a - b) < atol,
4198 "%s %s: %s; cmath: %s" % (fname, p, a, b)
4199 )
4200
4201 @pytest.mark.xfail(
4202 # manylinux2014 uses glibc2.17

Callers

nothing calls this directly

Calls 5

assert_Function · 0.90
absFunction · 0.85
funcFunction · 0.50
splitMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected