/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_records.py (20269B)
import collections.abc import textwrap from io import BytesIO from os import path from pathlib import Path import pytest import numpy as np from numpy.testing import ( assert_, assert_equal, assert_array_equal, assert_array_almost_equal, assert_raises, temppath, ) from numpy.compat import pickle class TestFromrecords: def test_fromrecords(self): r = np.rec.fromrecords([[456, 'dbe', 1.2], [2, 'de', 1.3]], names='col1,col2,col3') assert_equal(r[0].item(), (456, 'dbe', 1.2)) assert_equal(r['col1'].dtype.kind, 'i') assert_equal(r['col2'].dtype.kind, 'U') assert_equal(r['col2'].dtype.itemsize, 12) assert_equal(r['col3'].dtype.kind, 'f') def test_fromrecords_0len(self): """ Verify fromrecords works with a 0-length input """ dtype = [('a', float), ('b', float)] r = np.rec.fromrecords([], dtype=dtype) assert_equal(r.shape, (0,)) def test_fromrecords_2d(self): data = [ [(1, 2), (3, 4), (5, 6)], [(6, 5), (4, 3), (2, 1)] ] expected_a = [[1, 3, 5], [6, 4, 2]] expected_b = [[2, 4, 6], [5, 3, 1]] # try with dtype r1 = np.rec.fromrecords(data, dtype=[('a', int), ('b', int)]) assert_equal(r1['a'], expected_a) assert_equal(r1['b'], expected_b) # try with names r2 = np.rec.fromrecords(data, names=['a', 'b']) assert_equal(r2['a'], expected_a) assert_equal(r2['b'], expected_b) assert_equal(r1, r2) def test_method_array(self): r = np.rec.array(b'abcdefg' * 100, formats='i2,a3,i4', shape=3, byteorder='big') assert_equal(r[1].item(), (25444, b'efg', 1633837924)) def test_method_array2(self): r = np.rec.array([(1, 11, 'a'), (2, 22, 'b'), (3, 33, 'c'), (4, 44, 'd'), (5, 55, 'ex'), (6, 66, 'f'), (7, 77, 'g')], formats='u1,f4,a1') assert_equal(r[1].item(), (2, 22.0, b'b')) def test_recarray_slices(self): r = np.rec.array([(1, 11, 'a'), (2, 22, 'b'), (3, 33, 'c'), (4, 44, 'd'), (5, 55, 'ex'), (6, 66, 'f'), (7, 77, 'g')], formats='u1,f4,a1') assert_equal(r[1::2][1].item(), (4, 44.0, b'd')) def test_recarray_fromarrays(self): x1 = np.array([1, 2, 3, 4]) x2 = np.array(['a', 'dd', 'xyz', '12']) x3 = np.array([1.1, 2, 3, 4]) r = np.rec.fromarrays([x1, x2, x3], names='a,b,c') assert_equal(r[1].item(), (2, 'dd', 2.0)) x1[1] = 34 assert_equal(r.a, np.array([1, 2, 3, 4])) def test_recarray_fromfile(self): data_dir = path.join(path.dirname(__file__), 'data') filename = path.join(data_dir, 'recarray_from_file.fits') fd = open(filename, 'rb') fd.seek(2880 * 2) r1 = np.rec.fromfile(fd, formats='f8,i4,a5', shape=3, byteorder='big') fd.seek(2880 * 2) r2 = np.rec.array(fd, formats='f8,i4,a5', shape=3, byteorder='big') fd.seek(2880 * 2) bytes_array = BytesIO() bytes_array.write(fd.read()) bytes_array.seek(0) r3 = np.rec.fromfile(bytes_array, formats='f8,i4,a5', shape=3, byteorder='big') fd.close() assert_equal(r1, r2) assert_equal(r2, r3) def test_recarray_from_obj(self): count = 10 a = np.zeros(count, dtype='O') b = np.zeros(count, dtype='f8') c = np.zeros(count, dtype='f8') for i in range(len(a)): a[i] = list(range(1, 10)) mine = np.rec.fromarrays([a, b, c], names='date,data1,data2') for i in range(len(a)): assert_((mine.date[i] == list(range(1, 10)))) assert_((mine.data1[i] == 0.0)) assert_((mine.data2[i] == 0.0)) def test_recarray_repr(self): a = np.array([(1, 0.1), (2, 0.2)], dtype=[('foo', '