/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
numpy
/
core
/
tests
/
/usr/local/lib64/python3.6/site-packages/numpy/core/tests
mkdir
upload
Name
Size
Mode
Actions
data/
-
0755
rm
__pycache__/
-
0755
rm
test_abc.py
2328
0644
edit
dl
rm
test_api.py
20806
0644
edit
dl
rm
test_arrayprint.py
34493
0644
edit
dl
rm
test_conversion_utils.py
4981
0644
edit
dl
rm
test_cpu_features.py
6785
0644
edit
dl
rm
test_datetime.py
108192
0644
edit
dl
rm
test_defchararray.py
24381
0644
edit
dl
rm
test_deprecations.py
24187
0644
edit
dl
rm
test_dtype.py
49291
0644
edit
dl
rm
test_einsum.py
45197
0644
edit
dl
rm
test_errstate.py
2066
0644
edit
dl
rm
test_extint128.py
5643
0644
edit
dl
rm
test_function_base.py
13148
0644
edit
dl
rm
test_getlimits.py
4297
0644
edit
dl
rm
test_half.py
23102
0644
edit
dl
rm
test_indexerrors.py
5130
0644
edit
dl
rm
test_indexing.py
49260
0644
edit
dl
rm
test_item_selection.py
3579
0644
edit
dl
rm
test_longdouble.py
13041
0644
edit
dl
rm
test_machar.py
1066
0644
edit
dl
rm
test_memmap.py
7464
0644
edit
dl
rm
test_mem_overlap.py
28855
0644
edit
dl
rm
test_multiarray.py
319797
0644
edit
dl
rm
test_nditer.py
112298
0644
edit
dl
rm
test_numeric.py
124118
0644
edit
dl
rm
test_numerictypes.py
20846
0644
edit
dl
rm
test_overrides.py
14433
0644
edit
dl
rm
test_print.py
6737
0644
edit
dl
rm
test_protocols.py
1168
0644
edit
dl
rm
test_records.py
19694
0644
edit
dl
rm
test_regression.py
88840
0644
edit
dl
rm
test_scalarbuffer.py
4065
0644
edit
dl
rm
test_scalarinherit.py
2127
0644
edit
dl
rm
test_scalarmath.py
28565
0644
edit
dl
rm
test_scalarprint.py
15158
0644
edit
dl
rm
test_scalar_ctors.py
2580
0644
edit
dl
rm
test_scalar_methods.py
4063
0644
edit
dl
rm
test_shape_base.py
24679
0644
edit
dl
rm
test_ufunc.py
83978
0644
edit
dl
rm
test_umath.py
121442
0644
edit
dl
rm
test_umath_accuracy.py
3044
0644
edit
dl
rm
test_umath_complex.py
23145
0644
edit
dl
rm
test_unicode.py
12553
0644
edit
dl
rm
test__exceptions.py
2005
0644
edit
dl
rm
_locales.py
2192
0644
edit
dl
rm
__init__.py
0
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/numpy/core/tests/test_umath_accuracy.py
(3044B)
import numpy as np import platform from os import path import sys import pytest from ctypes import c_longlong, c_double, c_float, c_int, cast, pointer, POINTER from numpy.testing import assert_array_max_ulp from numpy.core._multiarray_umath import __cpu_features__ 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="avoid testing inconsistent platform " "library implementations") # convert string to hex function taken from: # https://stackoverflow.com/questions/1592158/convert-hex-to-float # def convert(s, datatype="np.float32"): i = int(s, 16) # convert from hex to a Python int if (datatype == "np.float64"): cp = pointer(c_longlong(i)) # make this into a c long long integer fp = cast(cp, POINTER(c_double)) # cast the int pointer to a double pointer else: cp = pointer(c_int(i)) # make this into a c integer fp = cast(cp, POINTER(c_float)) # cast the int pointer to a float pointer return fp.contents.value # dereference the pointer, get the float str_to_float = np.vectorize(convert) files = ['umath-validation-set-exp', 'umath-validation-set-log', 'umath-validation-set-sin', 'umath-validation-set-cos'] class TestAccuracy: @platform_skip def test_validate_transcendentals(self): with np.errstate(all='ignore'): for filename in files: data_dir = path.join(path.dirname(__file__), 'data') 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), data_subset['type'].astype(str)), dtype=eval(datatype)) outval = np.array(str_to_float(data_subset['output'].astype(str), data_subset['type'].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)
Save
cmd:
run