|
4 | 4 | import itertools
|
5 | 5 | import pytest
|
6 | 6 | import sys
|
| 7 | +import os |
7 | 8 | from fractions import Fraction
|
8 | 9 | from functools import reduce
|
9 | 10 |
|
|
17 | 18 | _gen_alignment_data, assert_array_almost_equal_nulp, assert_warns
|
18 | 19 | )
|
19 | 20 |
|
| 21 | +def get_glibc_version(): |
| 22 | + try: |
| 23 | + ver = os.confstr('CS_GNU_LIBC_VERSION').rsplit(' ')[1] |
| 24 | + except Exception as inst: |
| 25 | + ver = '0.0' |
| 26 | + |
| 27 | + return ver |
| 28 | + |
| 29 | + |
| 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") |
| 34 | + |
20 | 35 | def on_powerpc():
|
21 | 36 | """ True if we are running on a Power PC platform."""
|
22 | 37 | return platform.processor() == 'powerpc' or \
|
@@ -986,6 +1001,10 @@ def test_exp_values(self):
|
986 | 1001 | yf = np.array(y, dtype=dt)
|
987 | 1002 | assert_equal(np.exp(yf), xf)
|
988 | 1003 |
|
| 1004 | + # Older version of glibc may not raise the correct FP exceptions |
| 1005 | + # See: https://github.com/numpy/numpy/issues/19192 |
| 1006 | + @glibc_newerthan_2_17 |
| 1007 | + def test_exp_exceptions(self): |
989 | 1008 | with np.errstate(over='raise'):
|
990 | 1009 | assert_raises(FloatingPointError, np.exp, np.float32(100.))
|
991 | 1010 | assert_raises(FloatingPointError, np.exp, np.float32(1E19))
|
|
0 commit comments