Skip to content

Commit 444a721

Browse files
authored
Merge pull request numpy#20274 from h-vetinari/fix_15179
TST: Some fixes & refactoring around glibc-dependent skips in test_umath.py
2 parents 376ad69 + 22448b4 commit 444a721

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

numpy/core/tests/test_umath.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def get_glibc_version():
2828

2929

3030
glibcver = get_glibc_version()
31-
glibc_newerthan_2_17 = pytest.mark.xfail(
32-
glibcver != '0.0' and glibcver < '2.17',
33-
reason="Older glibc versions may not raise appropriate FP exceptions")
31+
glibc_older_than = lambda x: (glibcver != '0.0' and glibcver < x)
3432

3533
def on_powerpc():
3634
""" True if we are running on a Power PC platform."""
@@ -50,14 +48,6 @@ def bad_arcsinh():
5048
# The eps for float128 is 1-e33, so this is way bigger
5149
return abs((v1 / v2) - 1.0) > 1e-23
5250

53-
if platform.machine() == 'aarch64' and bad_arcsinh():
54-
skip_longcomplex_msg = ('Trig functions of np.longcomplex values known to be '
55-
'inaccurate on aarch64 for some compilation '
56-
'configurations, should be fixed by building on a '
57-
'platform using glibc>2.17')
58-
else:
59-
skip_longcomplex_msg = ''
60-
6151

6252
class _FilterInvalids:
6353
def setup(self):
@@ -1022,9 +1012,11 @@ def test_exp_values(self):
10221012
yf = np.array(y, dtype=dt)
10231013
assert_equal(np.exp(yf), xf)
10241014

1025-
# Older version of glibc may not raise the correct FP exceptions
10261015
# See: https://github.com/numpy/numpy/issues/19192
1027-
@glibc_newerthan_2_17
1016+
@pytest.mark.xfail(
1017+
glibc_older_than("2.17"),
1018+
reason="Older glibc versions may not raise appropriate FP exceptions"
1019+
)
10281020
def test_exp_exceptions(self):
10291021
with np.errstate(over='raise'):
10301022
assert_raises(FloatingPointError, np.exp, np.float32(100.))
@@ -1405,8 +1397,10 @@ def test_sincos_float32(self):
14051397
M = np.int_(N/20)
14061398
index = np.random.randint(low=0, high=N, size=M)
14071399
x_f32 = np.float32(np.random.uniform(low=-100.,high=100.,size=N))
1408-
# test coverage for elements > 117435.992f for which glibc is used
1409-
x_f32[index] = np.float32(10E+10*np.random.rand(M))
1400+
if not glibc_older_than("2.17"):
1401+
# test coverage for elements > 117435.992f for which glibc is used
1402+
# this is known to be problematic on old glibc, so skip it there
1403+
x_f32[index] = np.float32(10E+10*np.random.rand(M))
14101404
x_f64 = np.float64(x_f32)
14111405
assert_array_max_ulp(np.sin(x_f32), np.float32(np.sin(x_f64)), maxulp=2)
14121406
assert_array_max_ulp(np.cos(x_f32), np.float32(np.cos(x_f64)), maxulp=2)
@@ -3439,13 +3433,14 @@ def check(x, rtol):
34393433
x_series = np.logspace(-20, -3.001, 200)
34403434
x_basic = np.logspace(-2.999, 0, 10, endpoint=False)
34413435

3442-
if dtype is np.longcomplex:
3436+
if glibc_older_than("2.19") and dtype is np.longcomplex:
3437+
if (platform.machine() == 'aarch64' and bad_arcsinh()):
3438+
pytest.skip("Trig functions of np.longcomplex values known "
3439+
"to be inaccurate on aarch64 for some compilation "
3440+
"configurations.")
34433441
# It's not guaranteed that the system-provided arc functions
34443442
# are accurate down to a few epsilons. (Eg. on Linux 64-bit)
34453443
# So, give more leeway for long complex tests here:
3446-
# Can use 2.1 for > Ubuntu LTS Trusty (2014), glibc = 2.19.
3447-
if skip_longcomplex_msg:
3448-
pytest.skip(skip_longcomplex_msg)
34493444
check(x_series, 50.0*eps)
34503445
else:
34513446
check(x_series, 2.1*eps)

0 commit comments

Comments
 (0)