OXIESEC PANEL
- Current Dir:
/
/
usr
/
local
/
lib
/
python3.6
/
dist-packages
/
numpy
/
core
/
tests
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
__init__.py
0 bytes
10/28/2024 05:59:24 AM
rw-r--r--
📁
__pycache__
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
_locales.py
2.14 KB
10/28/2024 05:59:24 AM
rw-r--r--
📁
data
-
10/28/2024 05:59:26 AM
rwxr-xr-x
📄
test__exceptions.py
1.96 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_abc.py
2.27 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_api.py
20.32 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_arrayprint.py
33.68 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_conversion_utils.py
4.86 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_cpu_features.py
6.63 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_datetime.py
105.66 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_defchararray.py
23.81 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_deprecations.py
23.62 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_dtype.py
48.14 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_einsum.py
44.14 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_errstate.py
2.02 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_extint128.py
5.51 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_function_base.py
12.84 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_getlimits.py
4.2 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_half.py
22.56 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_indexerrors.py
5.01 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_indexing.py
48.11 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_item_selection.py
3.5 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_longdouble.py
12.74 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_machar.py
1.04 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_mem_overlap.py
28.18 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_memmap.py
7.29 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_multiarray.py
312.3 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_nditer.py
109.67 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_numeric.py
121.21 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_numerictypes.py
20.36 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_overrides.py
14.09 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_print.py
6.58 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_protocols.py
1.14 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_records.py
19.23 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_regression.py
86.76 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalar_ctors.py
2.52 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalar_methods.py
3.97 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalarbuffer.py
3.97 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalarinherit.py
2.08 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalarmath.py
27.9 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_scalarprint.py
14.8 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_shape_base.py
24.1 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_ufunc.py
82.01 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_umath.py
118.6 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_umath_accuracy.py
2.97 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_umath_complex.py
22.6 KB
10/28/2024 05:59:24 AM
rw-r--r--
📄
test_unicode.py
12.26 KB
10/28/2024 05:59:24 AM
rw-r--r--
Editing: test_umath_accuracy.py
Close
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)