MCPcopy Create free account
hub / github.com/numpy/numpy / test_roundtrip

Method test_roundtrip

numpy/core/tests/test_multiarray.py:7844–7912  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7842 assert_array_equal(obj, y2)
7843
7844 def test_roundtrip(self):
7845 x = np.array([1, 2, 3, 4, 5], dtype='i4')
7846 self._check_roundtrip(x)
7847
7848 x = np.array([[1, 2], [3, 4]], dtype=np.float64)
7849 self._check_roundtrip(x)
7850
7851 x = np.zeros((3, 3, 3), dtype=np.float32)[:, 0,:]
7852 self._check_roundtrip(x)
7853
7854 dt = [('a', 'b'),
7855 ('b', 'h'),
7856 ('c', 'i'),
7857 ('d', 'l'),
7858 ('dx', 'q'),
7859 ('e', 'B'),
7860 ('f', 'H'),
7861 ('g', 'I'),
7862 ('h', 'L'),
7863 ('hx', 'Q'),
7864 ('i', np.single),
7865 ('j', np.double),
7866 ('k', np.longdouble),
7867 ('ix', np.csingle),
7868 ('jx', np.cdouble),
7869 ('kx', np.clongdouble),
7870 ('l', 'S4'),
7871 ('m', 'U4'),
7872 ('n', 'V3'),
7873 ('o', '?'),
7874 ('p', np.half),
7875 ]
7876 x = np.array(
7877 [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7878 b'aaaa', 'bbbb', b'xxx', True, 1.0)],
7879 dtype=dt)
7880 self._check_roundtrip(x)
7881
7882 x = np.array(([[1, 2], [3, 4]],), dtype=[('a', (int, (2, 2)))])
7883 self._check_roundtrip(x)
7884
7885 x = np.array([1, 2, 3], dtype='>i2')
7886 self._check_roundtrip(x)
7887
7888 x = np.array([1, 2, 3], dtype='<i2')
7889 self._check_roundtrip(x)
7890
7891 x = np.array([1, 2, 3], dtype='>i4')
7892 self._check_roundtrip(x)
7893
7894 x = np.array([1, 2, 3], dtype='<i4')
7895 self._check_roundtrip(x)
7896
7897 # check long long can be represented as non-native
7898 x = np.array([1, 2, 3], dtype='>q')
7899 self._check_roundtrip(x)
7900
7901 # Native-only data types can be passed through the buffer interface

Callers

nothing calls this directly

Calls 2

_check_roundtripMethod · 0.95
assert_raisesFunction · 0.90

Tested by

no test coverage detected