-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
TST: Some fixes & refactoring around glibc-dependent skips in test_umath.py #20274
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
Changes from all commits
01443e8
56268d5
12923c2
22448b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,7 @@ def get_glibc_version(): | |
|
||
|
||
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") | ||
glibc_older_than = lambda x: (glibcver != '0.0' and glibcver < x) | ||
|
||
def on_powerpc(): | ||
""" True if we are running on a Power PC platform.""" | ||
|
@@ -50,14 +48,6 @@ def bad_arcsinh(): | |
# The eps for float128 is 1-e33, so this is way bigger | ||
return abs((v1 / v2) - 1.0) > 1e-23 | ||
|
||
if platform.machine() == 'aarch64' and bad_arcsinh(): | ||
skip_longcomplex_msg = ('Trig functions of np.longcomplex values known to be ' | ||
'inaccurate on aarch64 for some compilation ' | ||
'configurations, should be fixed by building on a ' | ||
'platform using glibc>2.17') | ||
else: | ||
skip_longcomplex_msg = '' | ||
|
||
|
||
class _FilterInvalids: | ||
def setup(self): | ||
|
@@ -1022,9 +1012,11 @@ 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 | ||
@pytest.mark.xfail( | ||
glibc_older_than("2.17"), | ||
reason="Older glibc versions may not raise appropriate FP exceptions" | ||
) | ||
def test_exp_exceptions(self): | ||
with np.errstate(over='raise'): | ||
assert_raises(FloatingPointError, np.exp, np.float32(100.)) | ||
|
@@ -1405,8 +1397,10 @@ def test_sincos_float32(self): | |
M = np.int_(N/20) | ||
index = np.random.randint(low=0, high=N, size=M) | ||
x_f32 = np.float32(np.random.uniform(low=-100.,high=100.,size=N)) | ||
# test coverage for elements > 117435.992f for which glibc is used | ||
x_f32[index] = np.float32(10E+10*np.random.rand(M)) | ||
if not glibc_older_than("2.17"): | ||
# test coverage for elements > 117435.992f for which glibc is used | ||
# this is known to be problematic on old glibc, so skip it there | ||
x_f32[index] = np.float32(10E+10*np.random.rand(M)) | ||
x_f64 = np.float64(x_f32) | ||
assert_array_max_ulp(np.sin(x_f32), np.float32(np.sin(x_f64)), maxulp=2) | ||
assert_array_max_ulp(np.cos(x_f32), np.float32(np.cos(x_f64)), maxulp=2) | ||
|
@@ -3439,13 +3433,14 @@ def check(x, rtol): | |
x_series = np.logspace(-20, -3.001, 200) | ||
x_basic = np.logspace(-2.999, 0, 10, endpoint=False) | ||
|
||
if dtype is np.longcomplex: | ||
if glibc_older_than("2.19") and dtype is np.longcomplex: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "2.19" or "2.18"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what that would do? If it's older than 2.18, ít's definitely older than 2.19? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was looking at the older comment that it was OK for glibc > 2.17. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the if-branches here, the pertinent part (being deleted) is:
I take from this comment that anything from glibc 2.19 onwards should be fine to take the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Right, I couldn't evaluate that corner case (2.18), so I went with the conservative choice, of still running the check (resp. the looser tolerance) with 2.18. Before the last commit, I actually had this as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, probably not worth worrying about. Manylinux2014 itself is getting towards end of life. |
||
if (platform.machine() == 'aarch64' and bad_arcsinh()): | ||
pytest.skip("Trig functions of np.longcomplex values known " | ||
"to be inaccurate on aarch64 for some compilation " | ||
"configurations.") | ||
# It's not guaranteed that the system-provided arc functions | ||
# are accurate down to a few epsilons. (Eg. on Linux 64-bit) | ||
# So, give more leeway for long complex tests here: | ||
# Can use 2.1 for > Ubuntu LTS Trusty (2014), glibc = 2.19. | ||
if skip_longcomplex_msg: | ||
pytest.skip(skip_longcomplex_msg) | ||
check(x_series, 50.0*eps) | ||
else: | ||
check(x_series, 2.1*eps) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of alphabetical order works, but it bothers me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree, but then, it was this way before already, and I didn't want to overengineer something for 3 tests...
What would you prefer? Comparing tuples? Using something like
distutils.version.LooseVersion
?