diff options
author | Stephan Hoyer <shoyer@google.com> | 2019-05-13 08:09:26 -0700 |
---|---|---|
committer | Stephan Hoyer <shoyer@google.com> | 2019-05-13 08:09:26 -0700 |
commit | 07452c86c78a1cf213a764d17f060b4887ec3681 (patch) | |
tree | 12c7ae7b14552bd28334277e7e244b603ca4300a /numpy/lib/tests/test_format.py | |
parent | 804f71bb42fef775a85a52366dc4bd1a22c130a8 (diff) | |
parent | 4ad33d21b1a30f931e23307e9f9355b70f633bed (diff) | |
download | numpy-07452c86c78a1cf213a764d17f060b4887ec3681.tar.gz |
Merge branch 'master' into implement-numpy-implementation
Diffstat (limited to 'numpy/lib/tests/test_format.py')
-rw-r--r-- | numpy/lib/tests/test_format.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 2ebd483d5..4a3fbdf57 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -411,6 +411,7 @@ record_arrays = [ np.array(NbufferT, dtype=np.dtype(Ndescr).newbyteorder('<')), np.array(PbufferT, dtype=np.dtype(Pdescr).newbyteorder('>')), np.array(NbufferT, dtype=np.dtype(Ndescr).newbyteorder('>')), + np.zeros(1, dtype=[('c', ('<f8', (5,)), (2,))]) ] @@ -628,6 +629,61 @@ def test_pickle_disallow(): assert_raises(ValueError, np.save, path, np.array([None], dtype=object), allow_pickle=False) +@pytest.mark.parametrize('dt', [ + np.dtype(np.dtype([('a', np.int8), + ('b', np.int16), + ('c', np.int32), + ], align=True), + (3,)), + np.dtype([('x', np.dtype({'names':['a','b'], + 'formats':['i1','i1'], + 'offsets':[0,4], + 'itemsize':8, + }, + (3,)), + (4,), + )]), + np.dtype([('x', + ('<f8', (5,)), + (2,), + )]), + np.dtype([('x', np.dtype(( + np.dtype(( + np.dtype({'names':['a','b'], + 'formats':['i1','i1'], + 'offsets':[0,4], + 'itemsize':8}), + (3,) + )), + (4,) + ))) + ]), + np.dtype([ + ('a', np.dtype(( + np.dtype(( + np.dtype(( + np.dtype([ + ('a', int), + ('b', np.dtype({'names':['a','b'], + 'formats':['i1','i1'], + 'offsets':[0,4], + 'itemsize':8})), + ]), + (3,), + )), + (4,), + )), + (5,), + ))) + ]), + ]) + +def test_descr_to_dtype(dt): + dt1 = format.descr_to_dtype(dt.descr) + assert_equal_(dt1, dt) + arr1 = np.zeros(3, dt) + arr2 = roundtrip(arr1) + assert_array_equal(arr1, arr2) def test_version_2_0(): f = BytesIO() |