@@ -28,9 +28,7 @@ def get_glibc_version():
28
28
29
29
30
30
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 )
34
32
35
33
def on_powerpc ():
36
34
""" True if we are running on a Power PC platform."""
@@ -50,14 +48,6 @@ def bad_arcsinh():
50
48
# The eps for float128 is 1-e33, so this is way bigger
51
49
return abs ((v1 / v2 ) - 1.0 ) > 1e-23
52
50
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
-
61
51
62
52
class _FilterInvalids :
63
53
def setup (self ):
@@ -1022,9 +1012,11 @@ def test_exp_values(self):
1022
1012
yf = np .array (y , dtype = dt )
1023
1013
assert_equal (np .exp (yf ), xf )
1024
1014
1025
- # Older version of glibc may not raise the correct FP exceptions
1026
1015
# 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
+ )
1028
1020
def test_exp_exceptions (self ):
1029
1021
with np .errstate (over = 'raise' ):
1030
1022
assert_raises (FloatingPointError , np .exp , np .float32 (100. ))
@@ -1405,8 +1397,10 @@ def test_sincos_float32(self):
1405
1397
M = np .int_ (N / 20 )
1406
1398
index = np .random .randint (low = 0 , high = N , size = M )
1407
1399
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 ))
1410
1404
x_f64 = np .float64 (x_f32 )
1411
1405
assert_array_max_ulp (np .sin (x_f32 ), np .float32 (np .sin (x_f64 )), maxulp = 2 )
1412
1406
assert_array_max_ulp (np .cos (x_f32 ), np .float32 (np .cos (x_f64 )), maxulp = 2 )
@@ -3439,13 +3433,14 @@ def check(x, rtol):
3439
3433
x_series = np .logspace (- 20 , - 3.001 , 200 )
3440
3434
x_basic = np .logspace (- 2.999 , 0 , 10 , endpoint = False )
3441
3435
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." )
3443
3441
# It's not guaranteed that the system-provided arc functions
3444
3442
# are accurate down to a few epsilons. (Eg. on Linux 64-bit)
3445
3443
# 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 )
3449
3444
check (x_series , 50.0 * eps )
3450
3445
else :
3451
3446
check (x_series , 2.1 * eps )
0 commit comments