/opt/imh-python/lib/python3.9/site-packages/numpy/core/tests
NameSizeModeActions
data/-0755rm
examples/-0755rm
__pycache__/-0755rm
test_abc.py22200644editdlrm
test_api.py229950644editdlrm
test_argparse.py19690644editdlrm
test_arraymethod.py32440644editdlrm
test_arrayprint.py404620644editdlrm
test_array_coercion.py343790644editdlrm
test_array_interface.py77740644editdlrm
test_casting_floatingpoint_errors.py50630644editdlrm
test_casting_unittests.py342980644editdlrm
test_conversion_utils.py65590644editdlrm
test_cpu_dispatcher.py15210644editdlrm
test_cpu_features.py148580644editdlrm
test_custom_dtypes.py94010644editdlrm
test_cython.py34440644editdlrm
test_datetime.py1162110644editdlrm
test_defchararray.py249970644editdlrm
test_deprecations.py310760644editdlrm
test_dlpack.py35220644editdlrm
test_dtype.py754510644editdlrm
test_einsum.py537120644editdlrm
test_errstate.py22190644editdlrm
test_extint128.py56430644editdlrm
test_function_base.py155950644editdlrm
test_getlimits.py67180644editdlrm
test_half.py242260644editdlrm
test_hashtable.py10110644editdlrm
test_indexerrors.py51300644editdlrm
test_indexing.py543140644editdlrm
test_item_selection.py64580644editdlrm
test_limited_api.py11720644editdlrm
test_longdouble.py139050644editdlrm
test_machar.py10670644editdlrm
test_memmap.py74770644editdlrm
test_mem_overlap.py290860644editdlrm
test_mem_policy.py167800644editdlrm
test_multiarray.py3798270644editdlrm
test_nditer.py1308180644editdlrm
test_nep50_promotions.py88400644editdlrm
test_numeric.py1365430644editdlrm
test_numerictypes.py216870644editdlrm
test_overrides.py260800644editdlrm
test_print.py68370644editdlrm
test_protocols.py11680644editdlrm
test_records.py202690644editdlrm
test_regression.py915950644editdlrm
test_scalarbuffer.py55800644editdlrm
test_scalarinherit.py23680644editdlrm
test_scalarmath.py432470644editdlrm
test_scalarprint.py187710644editdlrm
test_scalar_ctors.py61150644editdlrm
test_scalar_methods.py75410644editdlrm
test_shape_base.py297230644editdlrm
test_simd.py486960644editdlrm
test_simd_module.py38050644editdlrm
test_strings.py38350644editdlrm
test_ufunc.py1248000644editdlrm
test_umath.py1856010644editdlrm
test_umath_accuracy.py38970644editdlrm
test_umath_complex.py232430644editdlrm
test_unicode.py127750644editdlrm
test__exceptions.py28460644editdlrm
_locales.py22060644editdlrm
__init__.py00644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/numpy/core/tests/test_dlpack.py (3522B)
import sys import pytest import numpy as np from numpy.testing import assert_array_equal, IS_PYPY class TestDLPack: @pytest.mark.skipif(IS_PYPY, reason="PyPy can't get refcounts.") def test_dunder_dlpack_refcount(self): x = np.arange(5) y = x.__dlpack__() assert sys.getrefcount(x) == 3 del y assert sys.getrefcount(x) == 2 def test_dunder_dlpack_stream(self): x = np.arange(5) x.__dlpack__(stream=None) with pytest.raises(RuntimeError): x.__dlpack__(stream=1) def test_strides_not_multiple_of_itemsize(self): dt = np.dtype([('int', np.int32), ('char', np.int8)]) y = np.zeros((5,), dtype=dt) z = y['int'] with pytest.raises(BufferError): np.from_dlpack(z) @pytest.mark.skipif(IS_PYPY, reason="PyPy can't get refcounts.") def test_from_dlpack_refcount(self): x = np.arange(5) y = np.from_dlpack(x) assert sys.getrefcount(x) == 3 del y assert sys.getrefcount(x) == 2 @pytest.mark.parametrize("dtype", [ np.bool_, np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uint32, np.uint64, np.float16, np.float32, np.float64, np.complex64, np.complex128 ]) def test_dtype_passthrough(self, dtype): x = np.arange(5).astype(dtype) y = np.from_dlpack(x) assert y.dtype == x.dtype assert_array_equal(x, y) def test_invalid_dtype(self): x = np.asarray(np.datetime64('2021-05-27')) with pytest.raises(BufferError): np.from_dlpack(x) def test_invalid_byte_swapping(self): dt = np.dtype('=i8').newbyteorder() x = np.arange(5, dtype=dt) with pytest.raises(BufferError): np.from_dlpack(x) def test_non_contiguous(self): x = np.arange(25).reshape((5, 5)) y1 = x[0] assert_array_equal(y1, np.from_dlpack(y1)) y2 = x[:, 0] assert_array_equal(y2, np.from_dlpack(y2)) y3 = x[1, :] assert_array_equal(y3, np.from_dlpack(y3)) y4 = x[1] assert_array_equal(y4, np.from_dlpack(y4)) y5 = np.diagonal(x).copy() assert_array_equal(y5, np.from_dlpack(y5)) @pytest.mark.parametrize("ndim", range(33)) def test_higher_dims(self, ndim): shape = (1,) * ndim x = np.zeros(shape, dtype=np.float64) assert shape == np.from_dlpack(x).shape def test_dlpack_device(self): x = np.arange(5) assert x.__dlpack_device__() == (1, 0) y = np.from_dlpack(x) assert y.__dlpack_device__() == (1, 0) z = y[::2] assert z.__dlpack_device__() == (1, 0) def dlpack_deleter_exception(self): x = np.arange(5) _ = x.__dlpack__() raise RuntimeError def test_dlpack_destructor_exception(self): with pytest.raises(RuntimeError): self.dlpack_deleter_exception() def test_readonly(self): x = np.arange(5) x.flags.writeable = False with pytest.raises(BufferError): x.__dlpack__() def test_ndim0(self): x = np.array(1.0) y = np.from_dlpack(x) assert_array_equal(x, y) def test_size1dims_arrays(self): x = np.ndarray(dtype='f8', shape=(10, 5, 1), strides=(8, 80, 4), buffer=np.ones(1000, dtype=np.uint8), order='F') y = np.from_dlpack(x) assert_array_equal(x, y)