diff options
author | Allan Haldane <allan.haldane@gmail.com> | 2018-11-24 17:55:55 -0500 |
---|---|---|
committer | Allan Haldane <allan.haldane@gmail.com> | 2018-11-26 13:02:50 -0500 |
commit | 191d5c78383771e9a4825801062d0f23625410bf (patch) | |
tree | ec278b39faa2b9b174155cd0201f7437cf3965fe /numpy/lib/tests/test_recfunctions.py | |
parent | 11a316e1f5f7f8130bbd8184b1b0c46bccab01a5 (diff) | |
download | numpy-191d5c78383771e9a4825801062d0f23625410bf.tar.gz |
MAINT: Fixups to new functions in np.lib.recfunctions
Diffstat (limited to 'numpy/lib/tests/test_recfunctions.py')
-rw-r--r-- | numpy/lib/tests/test_recfunctions.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_recfunctions.py b/numpy/lib/tests/test_recfunctions.py index 7ec33d92a..11f8a5afa 100644 --- a/numpy/lib/tests/test_recfunctions.py +++ b/numpy/lib/tests/test_recfunctions.py @@ -241,6 +241,14 @@ class TestRecFunctions(object): assert_(dd.base is d) assert_(ddd.base is d) + # test that nested fields with identical names don't break anything + point = np.dtype([('x', int), ('y', int)]) + triangle = np.dtype([('a', point), ('b', point), ('c', point)]) + arr = np.zeros(10, triangle) + res = structured_to_unstructured(arr, dtype=int) + assert_equal(res, np.zeros((10, 6), dtype=int)) + + def test_field_assignment_by_name(self): a = np.ones(2, dtype=[('a', 'i4'), ('b', 'f8'), ('c', 'u1')]) newdt = [('b', 'f4'), ('c', 'u1')] @@ -263,6 +271,11 @@ class TestRecFunctions(object): assign_fields_by_name(a, b) assert_equal(a, np.array([((0,2),), ((0,3),)], dtype=a.dtype)) + # test unstructured code path for 0d arrays + a, b = np.array(3), np.array(0) + assign_fields_by_name(b, a) + assert_equal(b[()], 3) + class TestRecursiveFillFields(object): # Test recursive_fill_fields. |