summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-08-30 18:15:55 -0600
committerCharles Harris <charlesr.harris@gmail.com>2014-08-30 18:15:55 -0600
commit9c50f988ac27dd1758dbc46455573aaa77638c68 (patch)
tree962fe5433929148ad5fe2f24a4f3b193fcdbf6be /numpy/lib/tests/test_function_base.py
parent45f8a181b7518836986fd03fc94c3845730bde44 (diff)
parentf880b1aa7583d7c3dfc111a8b79e7e7ba364baf2 (diff)
downloadnumpy-9c50f988ac27dd1758dbc46455573aaa77638c68.tar.gz
Merge pull request #5022 from seberg/structured-insert
BUG: Fix np.insert for inserting a single item into a structured array
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index ee3000547..624b5f3eb 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -310,6 +310,16 @@ class TestInsert(TestCase):
np.insert([0, 1, 2], x, [3, 4, 5])
assert_equal(x, np.array([1, 1, 1]))
+ def test_structured_array(self):
+ a = np.array([(1, 'a'), (2, 'b'), (3, 'c')],
+ dtype=[('foo', 'i'), ('bar', 'a1')])
+ val = (4, 'd')
+ b = np.insert(a, 0, val)
+ assert_array_equal(b[0], np.array(val, dtype=b.dtype))
+ val = [(4, 'd')] * 2
+ b = np.insert(a, [0, 2], val)
+ assert_array_equal(b[[0, 3]], np.array(val, dtype=b.dtype))
+
class TestAmax(TestCase):
def test_basic(self):
@@ -1465,7 +1475,7 @@ class TestMeshgrid(TestCase):
# Test that meshgrid complains about invalid arguments
# Regression test for issue #4755:
# https://github.com/numpy/numpy/issues/4755
- assert_raises(TypeError, meshgrid,
+ assert_raises(TypeError, meshgrid,
[1, 2, 3], [4, 5, 6, 7], indices='ij')