X7ROOT File Manager
Current Path:
/opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/core/tests
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
numpy
/
core
/
tests
/
📁
..
📄
__init__.py
(0 B)
📁
__pycache__
📄
_locales.py
(2.15 KB)
📁
data
📁
examples
📄
test__exceptions.py
(2.78 KB)
📄
test_abc.py
(2.17 KB)
📄
test_api.py
(22.46 KB)
📄
test_argparse.py
(1.92 KB)
📄
test_array_coercion.py
(33.57 KB)
📄
test_array_interface.py
(7.42 KB)
📄
test_arraymethod.py
(3.17 KB)
📄
test_arrayprint.py
(39.51 KB)
📄
test_casting_floatingpoint_errors.py
(4.94 KB)
📄
test_casting_unittests.py
(33.49 KB)
📄
test_conversion_utils.py
(6.41 KB)
📄
test_cpu_dispatcher.py
(1.49 KB)
📄
test_cpu_features.py
(14.51 KB)
📄
test_custom_dtypes.py
(9.18 KB)
📄
test_cython.py
(3.54 KB)
📄
test_datetime.py
(113.49 KB)
📄
test_defchararray.py
(24.41 KB)
📄
test_deprecations.py
(30.35 KB)
📄
test_dlpack.py
(3.44 KB)
📄
test_dtype.py
(73.52 KB)
📄
test_einsum.py
(51.72 KB)
📄
test_errstate.py
(2.17 KB)
📄
test_extint128.py
(5.51 KB)
📄
test_function_base.py
(15.23 KB)
📄
test_getlimits.py
(6.56 KB)
📄
test_half.py
(23.66 KB)
📄
test_hashtable.py
(1011 B)
📄
test_indexerrors.py
(5.01 KB)
📄
test_indexing.py
(53.04 KB)
📄
test_item_selection.py
(6.31 KB)
📄
test_limited_api.py
(1.14 KB)
📄
test_longdouble.py
(13.58 KB)
📄
test_machar.py
(1.04 KB)
📄
test_mem_overlap.py
(28.4 KB)
📄
test_mem_policy.py
(15.63 KB)
📄
test_memmap.py
(7.3 KB)
📄
test_multiarray.py
(370.43 KB)
📄
test_nditer.py
(127.75 KB)
📄
test_nep50_promotions.py
(8.63 KB)
📄
test_numeric.py
(133.34 KB)
📄
test_numerictypes.py
(21.18 KB)
📄
test_overrides.py
(25.47 KB)
📄
test_print.py
(6.68 KB)
📄
test_protocols.py
(1.14 KB)
📄
test_records.py
(19.79 KB)
📄
test_regression.py
(89.3 KB)
📄
test_scalar_ctors.py
(5.97 KB)
📄
test_scalar_methods.py
(7.36 KB)
📄
test_scalarbuffer.py
(5.45 KB)
📄
test_scalarinherit.py
(2.31 KB)
📄
test_scalarmath.py
(41.88 KB)
📄
test_scalarprint.py
(18.33 KB)
📄
test_shape_base.py
(29.03 KB)
📄
test_simd.py
(47.55 KB)
📄
test_simd_module.py
(3.72 KB)
📄
test_strings.py
(3.75 KB)
📄
test_ufunc.py
(121.24 KB)
📄
test_umath.py
(180.79 KB)
📄
test_umath_accuracy.py
(3.81 KB)
📄
test_umath_complex.py
(22.7 KB)
📄
test_unicode.py
(12.48 KB)
Editing: test__exceptions.py
""" Tests of the ._exceptions module. Primarily for exercising the __str__ methods. """ import pickle import pytest import numpy as np _ArrayMemoryError = np.core._exceptions._ArrayMemoryError _UFuncNoLoopError = np.core._exceptions._UFuncNoLoopError class TestArrayMemoryError: def test_pickling(self): """ Test that _ArrayMemoryError can be pickled """ error = _ArrayMemoryError((1023,), np.dtype(np.uint8)) res = pickle.loads(pickle.dumps(error)) assert res._total_size == error._total_size def test_str(self): e = _ArrayMemoryError((1023,), np.dtype(np.uint8)) str(e) # not crashing is enough # testing these properties is easier than testing the full string repr def test__size_to_string(self): """ Test e._size_to_string """ f = _ArrayMemoryError._size_to_string Ki = 1024 assert f(0) == '0 bytes' assert f(1) == '1 bytes' assert f(1023) == '1023 bytes' assert f(Ki) == '1.00 KiB' assert f(Ki+1) == '1.00 KiB' assert f(10*Ki) == '10.0 KiB' assert f(int(999.4*Ki)) == '999. KiB' assert f(int(1023.4*Ki)) == '1023. KiB' assert f(int(1023.5*Ki)) == '1.00 MiB' assert f(Ki*Ki) == '1.00 MiB' # 1023.9999 Mib should round to 1 GiB assert f(int(Ki*Ki*Ki*0.9999)) == '1.00 GiB' assert f(Ki*Ki*Ki*Ki*Ki*Ki) == '1.00 EiB' # larger than sys.maxsize, adding larger prefixes isn't going to help # anyway. assert f(Ki*Ki*Ki*Ki*Ki*Ki*123456) == '123456. EiB' def test__total_size(self): """ Test e._total_size """ e = _ArrayMemoryError((1,), np.dtype(np.uint8)) assert e._total_size == 1 e = _ArrayMemoryError((2, 4), np.dtype((np.uint64, 16))) assert e._total_size == 1024 class TestUFuncNoLoopError: def test_pickling(self): """ Test that _UFuncNoLoopError can be pickled """ assert isinstance(pickle.dumps(_UFuncNoLoopError), bytes) @pytest.mark.parametrize("args", [ (2, 1, None), (2, 1, "test_prefix"), ("test message",), ]) class TestAxisError: def test_attr(self, args): """Validate attribute types.""" exc = np.AxisError(*args) if len(args) == 1: assert exc.axis is None assert exc.ndim is None else: axis, ndim, *_ = args assert exc.axis == axis assert exc.ndim == ndim def test_pickling(self, args): """Test that `AxisError` can be pickled.""" exc = np.AxisError(*args) exc2 = pickle.loads(pickle.dumps(exc)) assert type(exc) is type(exc2) for name in ("axis", "ndim", "args"): attr1 = getattr(exc, name) attr2 = getattr(exc2, name) assert attr1 == attr2, name
Upload File
Create Folder