diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-07-22 18:48:42 +0100 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2018-07-22 18:48:42 +0100 |
commit | 9841981c3533d36582c2bd4d1fe24208de99f82f (patch) | |
tree | 5d4786bb085932257b3fd62fe468fbb67cafbbb0 /numpy/core | |
parent | c9ffde629b0f10255714b84fe75681c7f9fc4251 (diff) | |
download | numpy-9841981c3533d36582c2bd4d1fe24208de99f82f.tar.gz |
TST: Add a test of jagged array construction
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 07d1361d6..3812a20d8 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -688,6 +688,9 @@ class TestScalarIndexing(object): class TestCreation(object): + """ + Test the np.array constructor + """ def test_from_attribute(self): class x(object): def __array__(self, dtype=None): @@ -917,6 +920,21 @@ class TestCreation(object): assert_equal(a.shape, (3,)) assert_equal(a.dtype, object) + def test_jagged_shape_object(self): + # The jagged dimension of a list is turned into an object array + a = np.array([[1, 1], [2], [3]]) + assert_equal(a.shape, (3,)) + assert_equal(a.dtype, object) + + a = np.array([[1], [2, 2], [3]]) + assert_equal(a.shape, (3,)) + assert_equal(a.dtype, object) + + a = np.array([[1], [2], [3, 3]]) + assert_equal(a.shape, (3,)) + assert_equal(a.dtype, object) + + class TestStructured(object): def test_subarray_field_access(self): a = np.zeros((3, 5), dtype=[('a', ('i4', (2, 2)))]) |