summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_recfunctions.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-11-29 08:11:53 -0600
committerGitHub <noreply@github.com>2018-11-29 08:11:53 -0600
commitb3a435305082699c26445630d9c79587d51ba9f1 (patch)
tree2bef78f560ab641048e4f88ab0a26662042cdbcd /numpy/lib/tests/test_recfunctions.py
parentae6c0e8969ecf37a4f7548d15d6139358f7eeeaa (diff)
parent191d5c78383771e9a4825801062d0f23625410bf (diff)
downloadnumpy-b3a435305082699c26445630d9c79587d51ba9f1.tar.gz
Merge pull request #12446 from ahaldane/recfunctions_fixups
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.py13
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.