Skip to content

TST: Ignore exp FP exceptions test for glibc ver < 2.17 #19233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions numpy/core/tests/test_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import itertools
import pytest
import sys
import os
from fractions import Fraction
from functools import reduce

Expand All @@ -17,6 +18,20 @@
_gen_alignment_data, assert_array_almost_equal_nulp, assert_warns
)

def get_glibc_version():
try:
ver = os.confstr('CS_GNU_LIBC_VERSION').rsplit(' ')[1]
except Exception as inst:
ver = '0.0'

return ver


glibcver = get_glibc_version()
glibc_newerthan_2_17 = pytest.mark.xfail(
glibcver != '0.0' and glibcver < '2.17',
reason="Older glibc versions may not raise appropriate FP exceptions")

def on_powerpc():
""" True if we are running on a Power PC platform."""
return platform.processor() == 'powerpc' or \
Expand Down Expand Up @@ -986,6 +1001,10 @@ def test_exp_values(self):
yf = np.array(y, dtype=dt)
assert_equal(np.exp(yf), xf)

# Older version of glibc may not raise the correct FP exceptions
# See: https://github.com/numpy/numpy/issues/19192
@glibc_newerthan_2_17
def test_exp_exceptions(self):
with np.errstate(over='raise'):
assert_raises(FloatingPointError, np.exp, np.float32(100.))
assert_raises(FloatingPointError, np.exp, np.float32(1E19))
Expand Down