diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2013-12-20 16:35:00 +0100 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2013-12-20 16:43:11 +0100 |
commit | c91b4c3703eef84eca84063994d07332020c7707 (patch) | |
tree | de60bf6d9d7c77c243ac48ab934873f054a9e1ff /numpy/lib/tests/test_shape_base.py | |
parent | 056ab73e567b8dae84055108dee6166d637baa57 (diff) | |
download | numpy-c91b4c3703eef84eca84063994d07332020c7707.tar.gz |
BUG: Fix array_split empty array type and add FutureWarning
Fixes the result type of empty output arrays.
The FutureWarning warns about changed behaviour. A "kludge" was
introduced into array split converting converting the result of
something like:
>>> np.array_split(np.array([[1, 1]]), 2)
[array([[1, 1]]), array([], dtype=int64)]
instead of retaining the shape of the empty/second array to
be (0, 2). A FutureWarning is now raised when such a
replacement occurs.
Closes gh-612
Diffstat (limited to 'numpy/lib/tests/test_shape_base.py')
-rw-r--r-- | numpy/lib/tests/test_shape_base.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py index 55b008871..d6d01ba99 100644 --- a/numpy/lib/tests/test_shape_base.py +++ b/numpy/lib/tests/test_shape_base.py @@ -100,9 +100,12 @@ class TestArraySplit(TestCase): def test_integer_split_2D_rows(self): a = array([arange(10), arange(10)]) - res = array_split(a, 3, axis=0) + res = assert_warns(FutureWarning, array_split, a, 3, axis=0) + + # After removing the FutureWarning, the last should be zeros((0, 10)) desired = [array([arange(10)]), array([arange(10)]), array([])] compare_results(res, desired) + assert_(a.dtype.type is res[-1].dtype.type) def test_integer_split_2D_cols(self): a = array([arange(10), arange(10)]) @@ -116,9 +119,12 @@ class TestArraySplit(TestCase): """ This will fail if we change default axis """ a = array([arange(10), arange(10)]) - res = array_split(a, 3) + res = assert_warns(FutureWarning, array_split, a, 3) + + # After removing the FutureWarning, the last should be zeros((0, 10)) desired = [array([arange(10)]), array([arange(10)]), array([])] compare_results(res, desired) + assert_(a.dtype.type is res[-1].dtype.type) #perhaps should check higher dimensions def test_index_split_simple(self): |