summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2020-02-16 16:59:34 +0200
committerGitHub <noreply@github.com>2020-02-16 16:59:34 +0200
commitcd02ddc9c0ea2b7f5f879c0564709eabcec6f1af (patch)
tree25ca81ea950fcf3d1344ea7a80ae1ee9c469e05d /numpy
parent8a1592844f98e26a181ab2c1fc8f2e6fd3647f00 (diff)
parent0a5eb43ac221446ebf6261d7da563c49a28a0b6c (diff)
downloadnumpy-cd02ddc9c0ea2b7f5f879c0564709eabcec6f1af.tar.gz
Merge pull request #15549 from r-devulap/transcendental-avx
TST: Accuracy test float32 sin/cos/exp/log for AVX platforms
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_umath_accuracy.py44
1 files changed, 22 insertions, 22 deletions
diff --git a/numpy/core/tests/test_umath_accuracy.py b/numpy/core/tests/test_umath_accuracy.py
index 32211974c..f3281e418 100644
--- a/numpy/core/tests/test_umath_accuracy.py
+++ b/numpy/core/tests/test_umath_accuracy.py
@@ -5,14 +5,14 @@ import sys
import pytest
from ctypes import c_float, c_int, cast, pointer, POINTER
from numpy.testing import assert_array_max_ulp
+from numpy.core._multiarray_umath import __cpu_features__
-runtest = sys.platform.startswith('linux') and (platform.machine() == 'x86_64')
+IS_AVX = __cpu_features__.get('AVX512F', False) or \
+ (__cpu_features__.get('FMA3', False) and __cpu_features__.get('AVX2', False))
+runtest = sys.platform.startswith('linux') and IS_AVX
platform_skip = pytest.mark.skipif(not runtest,
- reason="""
- stick to x86_64 and linux platforms.
- test seems to fail on some of ARM and power
- architectures.
- """)
+ reason="avoid testing inconsistent platform "
+ "library implementations")
# convert string to hex function taken from:
# https://stackoverflow.com/questions/1592158/convert-hex-to-float #
@@ -29,7 +29,7 @@ files = ['umath-validation-set-exp',
'umath-validation-set-cos']
class TestAccuracy:
- @pytest.mark.xfail(reason="Fails for MacPython/numpy-wheels builds")
+ @platform_skip
def test_validate_transcendentals(self):
with np.errstate(all='ignore'):
for filename in files:
@@ -37,18 +37,18 @@ class TestAccuracy:
filepath = path.join(data_dir, filename)
with open(filepath) as fid:
file_without_comments = (r for r in fid if not r[0] in ('$', '#'))
- data = np.genfromtxt(file_without_comments,
- dtype=('|S39','|S39','|S39',int),
- names=('type','input','output','ulperr'),
- delimiter=',',
- skip_header=1)
- npfunc = getattr(np, filename.split('-')[3])
- for datatype in np.unique(data['type']):
- data_subset = data[data['type'] == datatype]
- inval = np.array(str_to_float(data_subset['input'].astype(str)), dtype=eval(datatype))
- outval = np.array(str_to_float(data_subset['output'].astype(str)), dtype=eval(datatype))
- perm = np.random.permutation(len(inval))
- inval = inval[perm]
- outval = outval[perm]
- maxulperr = data_subset['ulperr'].max()
- assert_array_max_ulp(npfunc(inval), outval, maxulperr)
+ data = np.genfromtxt(file_without_comments,
+ dtype=('|S39','|S39','|S39',int),
+ names=('type','input','output','ulperr'),
+ delimiter=',',
+ skip_header=1)
+ npfunc = getattr(np, filename.split('-')[3])
+ for datatype in np.unique(data['type']):
+ data_subset = data[data['type'] == datatype]
+ inval = np.array(str_to_float(data_subset['input'].astype(str)), dtype=eval(datatype))
+ outval = np.array(str_to_float(data_subset['output'].astype(str)), dtype=eval(datatype))
+ perm = np.random.permutation(len(inval))
+ inval = inval[perm]
+ outval = outval[perm]
+ maxulperr = data_subset['ulperr'].max()
+ assert_array_max_ulp(npfunc(inval), outval, maxulperr)