summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2019-05-02 11:29:10 -0400
committermattip <matti.picus@gmail.com>2019-05-03 02:28:06 -0400
commitb90addd13f17d967d81dc1d7515887d4fcd6ef59 (patch)
tree218e91b081078123e279ef268c8969cf07fb10bb /numpy/lib/tests
parent666d92ac85a6adf0fec7361c3340fc6ab12c8330 (diff)
downloadnumpy-b90addd13f17d967d81dc1d7515887d4fcd6ef59.tar.gz
BUG: parse more subarrays in descr_to_dtype
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_format.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py
index 9d12fafc0..a3ac89cdd 100644
--- a/numpy/lib/tests/test_format.py
+++ b/numpy/lib/tests/test_format.py
@@ -629,6 +629,50 @@ 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', ([('a', '|i1'),
+ ('', '|V3'),
+ ('b', '|i1'),
+ ('', '|V3'),
+ ],
+ (3,)),
+ (4,),
+ )]),
+ 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,)
+ )))
+ ])
+ ])
+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()