8000 TST: Ignore exp FP exceptions test for glibc ver < 2.17 by r-devulap · Pull Request #19209 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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

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 12, 2021
Merged
Changes from 2 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
35 changes: 24 additions & 11 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,15 @@
_gen_alignment_data, assert_array_almost_equal_nulp, assert_warns
)

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

return ver

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

with np.errstate(over='raise'):
assert_raises(FloatingPointError, np.exp, np.float32(100.))
assert_raises(FloatingPointError, np.exp, np.float32(1E19))
assert_raises(FloatingPointError, np.exp, np.float64(800.))
assert_raises(FloatingPointError, np.exp, np.float64(1E19))

with np.errstate(under='raise'):
assert_raises(FloatingPointError, np.exp, np.float32(-1000.))
assert_raises(FloatingPointError, np.exp, np.float32(-1E19))
assert_raises(FloatingPointError, np.exp, np.float64(-1000.))
assert_raises(FloatingPointError, np.exp, np.float64(-1E19))
# Older version of glibc may not raise the correct FP exceptions
# See: https://github.com/numpy/numpy/issues/19192
if (get_glibc_version() >= 2.17):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Older version of glibc may not raise the correct FP exceptions
# See: https://github.com/numpy/numpy/issues/19192
if (get_glibc_version() >= 2.17):
# Older version of glibc may not raise the correct FP exceptions
# See: https://github.com/numpy/numpy/issues/19192
# The check for ==0 is the fallback for non-glibc systems
if (get_glibc_version() >= 2.17 or get_glibc_version() == 0):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, fixed it. Works on windows now.

with np.errstate(over='raise'):
assert_raises(FloatingPointError, np.exp, np.float32(100.))
assert_raises(FloatingPointError, np.exp, np.float32(1E19))
assert_raises(FloatingPointError, np.exp, np.float64(800.))
assert_raises(FloatingPointError, np.exp, np.float64(1E19))

with np.errstate(under='raise'):
assert_raises(FloatingPointError, np.exp, np.float32(-1000.))
assert_raises(FloatingPointError, np.exp, np.float32(-1E19))
assert_raises(FloatingPointError, np.exp, np.float64(-1000.))
assert_raises(FloatingPointError, np.exp, np.float64(-1E19))

def test_log_values(self):
with np.errstate(all='ignore'):
Expand Down
0