golden hour
/opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/core/tests
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.py
0 B
Del
OK
__pycache__
-
Del
OK
_locales.py
2.15 KB
Del
OK
data
-
Del
OK
examples
-
Del
OK
test__exceptions.py
2.78 KB
Del
OK
test_abc.py
2.17 KB
Del
OK
test_api.py
22.46 KB
Del
OK
test_argparse.py
1.92 KB
Del
OK
test_array_coercion.py
33.57 KB
Del
OK
test_array_interface.py
7.42 KB
Del
OK
test_arraymethod.py
3.17 KB
Del
OK
test_arrayprint.py
39.51 KB
Del
OK
test_casting_floatingpoint_errors.py
4.94 KB
Del
OK
test_casting_unittests.py
33.49 KB
Del
OK
test_conversion_utils.py
6.41 KB
Del
OK
test_cpu_dispatcher.py
1.49 KB
Del
OK
test_cpu_features.py
14.51 KB
Del
OK
test_custom_dtypes.py
9.18 KB
Del
OK
test_cython.py
3.54 KB
Del
OK
test_datetime.py
113.49 KB
Del
OK
test_defchararray.py
24.41 KB
Del
OK
test_deprecations.py
30.35 KB
Del
OK
test_dlpack.py
3.44 KB
Del
OK
test_dtype.py
73.52 KB
Del
OK
test_einsum.py
51.72 KB
Del
OK
test_errstate.py
2.17 KB
Del
OK
test_extint128.py
5.51 KB
Del
OK
test_function_base.py
15.23 KB
Del
OK
test_getlimits.py
6.56 KB
Del
OK
test_half.py
23.66 KB
Del
OK
test_hashtable.py
1011 B
Del
OK
test_indexerrors.py
5.01 KB
Del
OK
test_indexing.py
53.04 KB
Del
OK
test_item_selection.py
6.31 KB
Del
OK
test_limited_api.py
1.14 KB
Del
OK
test_longdouble.py
13.58 KB
Del
OK
test_machar.py
1.04 KB
Del
OK
test_mem_overlap.py
28.4 KB
Del
OK
test_mem_policy.py
15.63 KB
Del
OK
test_memmap.py
7.3 KB
Del
OK
test_multiarray.py
370.43 KB
Del
OK
test_nditer.py
127.75 KB
Del
OK
test_nep50_promotions.py
8.63 KB
Del
OK
test_numeric.py
133.34 KB
Del
OK
test_numerictypes.py
21.18 KB
Del
OK
test_overrides.py
25.47 KB
Del
OK
test_print.py
6.68 KB
Del
OK
test_protocols.py
1.14 KB
Del
OK
test_records.py
19.79 KB
Del
OK
test_regression.py
89.3 KB
Del
OK
test_scalar_ctors.py
5.97 KB
Del
OK
test_scalar_methods.py
7.36 KB
Del
OK
test_scalarbuffer.py
5.45 KB
Del
OK
test_scalarinherit.py
2.31 KB
Del
OK
test_scalarmath.py
41.88 KB
Del
OK
test_scalarprint.py
18.33 KB
Del
OK
test_shape_base.py
29.03 KB
Del
OK
test_simd.py
47.55 KB
Del
OK
test_simd_module.py
3.72 KB
Del
OK
test_strings.py
3.75 KB
Del
OK
test_ufunc.py
121.24 KB
Del
OK
test_umath.py
180.79 KB
Del
OK
test_umath_accuracy.py
3.81 KB
Del
OK
test_umath_complex.py
22.7 KB
Del
OK
test_unicode.py
12.48 KB
Del
OK
Edit: test_simd_module.py
import pytest from numpy.core._simd import targets """ This testing unit only for checking the sanity of common functionality, therefore all we need is just to take one submodule that represents any of enabled SIMD extensions to run the test on it and the second submodule required to run only one check related to the possibility of mixing the data types among each submodule. """ npyvs = [npyv_mod for npyv_mod in targets.values() if npyv_mod and npyv_mod.simd] npyv, npyv2 = (npyvs + [None, None])[:2] unsigned_sfx = ["u8", "u16", "u32", "u64"] signed_sfx = ["s8", "s16", "s32", "s64"] fp_sfx = [] if npyv and npyv.simd_f32: fp_sfx.append("f32") if npyv and npyv.simd_f64: fp_sfx.append("f64") int_sfx = unsigned_sfx + signed_sfx all_sfx = unsigned_sfx + int_sfx @pytest.mark.skipif(not npyv, reason="could not find any SIMD extension with NPYV support") class Test_SIMD_MODULE: @pytest.mark.parametrize('sfx', all_sfx) def test_num_lanes(self, sfx): nlanes = getattr(npyv, "nlanes_" + sfx) vector = getattr(npyv, "setall_" + sfx)(1) assert len(vector) == nlanes @pytest.mark.parametrize('sfx', all_sfx) def test_type_name(self, sfx): vector = getattr(npyv, "setall_" + sfx)(1) assert vector.__name__ == "npyv_" + sfx def test_raises(self): a, b = [npyv.setall_u32(1)]*2 for sfx in all_sfx: vcb = lambda intrin: getattr(npyv, f"{intrin}_{sfx}") pytest.raises(TypeError, vcb("add"), a) pytest.raises(TypeError, vcb("add"), a, b, a) pytest.raises(TypeError, vcb("setall")) pytest.raises(TypeError, vcb("setall"), [1]) pytest.raises(TypeError, vcb("load"), 1) pytest.raises(ValueError, vcb("load"), [1]) pytest.raises(ValueError, vcb("store"), [1], getattr(npyv, f"reinterpret_{sfx}_u32")(a)) @pytest.mark.skipif(not npyv2, reason=( "could not find a second SIMD extension with NPYV support" )) def test_nomix(self): # mix among submodules isn't allowed a = npyv.setall_u32(1) a2 = npyv2.setall_u32(1) pytest.raises(TypeError, npyv.add_u32, a2, a2) pytest.raises(TypeError, npyv2.add_u32, a, a) @pytest.mark.parametrize('sfx', unsigned_sfx) def test_unsigned_overflow(self, sfx): nlanes = getattr(npyv, "nlanes_" + sfx) maxu = (1 << int(sfx[1:])) - 1 maxu_72 = (1 << 72) - 1 lane = getattr(npyv, "setall_" + sfx)(maxu_72)[0] assert lane == maxu lanes = getattr(npyv, "load_" + sfx)([maxu_72] * nlanes) assert lanes == [maxu] * nlanes lane = getattr(npyv, "setall_" + sfx)(-1)[0] assert lane == maxu lanes = getattr(npyv, "load_" + sfx)([-1] * nlanes) assert lanes == [maxu] * nlanes @pytest.mark.parametrize('sfx', signed_sfx) def test_signed_overflow(self, sfx): nlanes = getattr(npyv, "nlanes_" + sfx) maxs_72 = (1 << 71) - 1 lane = getattr(npyv, "setall_" + sfx)(maxs_72)[0] assert lane == -1 lanes = getattr(npyv, "load_" + sfx)([maxs_72] * nlanes) assert lanes == [-1] * nlanes mins_72 = -1 << 71 lane = getattr(npyv, "setall_" + sfx)(mins_72)[0] assert lane == 0 lanes = getattr(npyv, "load_" + sfx)([mins_72] * nlanes) assert lanes == [0] * nlanes def test_truncate_f32(self): f32 = npyv.setall_f32(0.1)[0] assert f32 != 0.1 assert round(f32, 1) == 0.1 def test_compare(self): data_range = range(0, npyv.nlanes_u32) vdata = npyv.load_u32(data_range) assert vdata == list(data_range) assert vdata == tuple(data_range) for i in data_range: assert vdata[i] == data_range[i]
Save