Tried this at the EuroScipy2018 sprints.
"numpy/core/tests/test_umath.py::TestComplexFunctions::()::test_branch_cuts",
"numpy/core/tests/test_umath.py::TestComplexFunctions::()::test_branch_cuts_complex64",
"numpy/core/tests/test_umath.py::TestComplexFunctions::()::test_loss_of_precision",
_________________ TestComplexFunctions.test_loss_of_precision _________________
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x000000000ADC6C88>
def test_loss_of_precision(self):
for dtype in [np.complex64, np.complex_]:
> self.check_loss_of_precision(dtype)
dtype = <class 'numpy.complex64'>
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x000000000ADC6C88>
numpy\core\tests\test_umath.py:2637:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x000000000ADC6C88>
dtype = <class 'numpy.complex64'>
def check_loss_of_precision(self, dtype):
"""Check loss of precision in complex arc* functions"""
# Check against known-good functions
info = np.finfo(dtype)
real_dtype = dtype(0.).real.dtype
eps = info.eps
def check(x, rtol):
x = x.astype(real_dtype)
z = x.astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsinh(z).real - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsinh'))
z = (1j*x).astype(dtype)
d = np.absolute(np.arcsinh(x)/np.arcsin(z).imag - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arcsin'))
z = x.astype(dtype)
d = np.absolute(np.arctanh(x)/np.arctanh(z).real - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arctanh'))
z = (1j*x).astype(dtype)
d = np.absolute(np.arctanh(x)/np.arctan(z).imag - 1)
assert_(np.all(d < rtol), (np.argmax(d), x[np.argmax(d)], d.max(),
'arctan'))
# The switchover was chosen as 1e-3; hence there can be up to
# ~eps/1e-3 of relative cancellation error before it
x_series = np.logspace(-20, -3.001, 200)
x_basic = np.logspace(-2.999, 0, 10, endpoint=False)
if dtype is np.longcomplex:
# It's not guaranteed that the system-provided arc functions
# are accurate down to a few epsilons. (Eg. on Linux 64-bit)
# So, give more leeway for long complex tests here:
check(x_series, 50*eps)
else:
check(x_series, 2.1*eps)
check(x_basic, 2*eps/1e-3)
# Check a few points
z = np.array([1e-5*(1+1j)], dtype=dtype)
p = 9.999999999333333333e-6 + 1.000000000066666666e-5j
d = np.absolute(1-np.arctanh(z)/p)
> assert_(np.all(d < 1e-15))
E AssertionError
check = <function TestComplexFunctions.check_loss_of_precision.<locals>.check at 0x000000000AEAF8C8>
d = array([4.5474735e-08], dtype=float32)
dtype = <class 'numpy.complex64'>
eps = 1.1920929e-07
info = finfo(resolution=1e-06, min=-3.4028235e+38, max=3.4028235e+38, dtype=float32)
p = (9.999999999333333e-06+1.0000000000666667e-05j)
real_dtype = dtype('float32')
self = <numpy.core.tests.test_umath.TestComplexFunctions object at 0x000000000ADC6C88>
x_basic = array([0.00100231, 0.0019994 , 0.00398841, 0.0079561 , 0.01587084,
0.0316592 , 0.06315387, 0.12597953, 0.25130435, 0.50130265])
x_series = array([1.00000000e-20, 1.21736864e-20, 1.48198641e-20, 1.80412378e-20,
2.19628372e-20, 2.67368693e-20, 3.254862...3.06526013e-04, 3.73155156e-04, 4.54267386e-04,
5.53010871e-04, 6.73218092e-04, 8.19554595e-04, 9.97700064e-04])
z = array([1.e-05+1.e-05j], dtype=complex64)
numpy\core\tests\test_umath.py:2602: AssertionError
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45)
[MSC v.1900 64 bit (AMD64)] on win32
Tried this at the EuroScipy2018 sprints.
Running
python runtests.pyon Windows 7 with ananconda, some tests involving complex64 fail. SpecificallyHere is one of the failures:
Numpy/Python version information:
This is from latest HEAD of NumPy, python version