diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2018-10-29 15:05:55 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-29 15:05:55 -0500 |
| commit | e726c045c72833d5c826e8a13f889746ee0bfdf4 (patch) | |
| tree | dc337946b0785d365ba23f4c7b7b22060b51d8be /numpy/lib | |
| parent | b2b532081b4b7fc15f97ffedb30a975aef835137 (diff) | |
| parent | 00640218fcbc5d71f22550a9368da92358c8de96 (diff) | |
| download | numpy-e726c045c72833d5c826e8a13f889746ee0bfdf4.tar.gz | |
Merge pull request #12280 from shoyer/stack-generator-warning
DEP: deprecate passing a generator to stack functions
Diffstat (limited to 'numpy/lib')
| -rw-r--r-- | numpy/lib/shape_base.py | 5 | ||||
| -rw-r--r-- | numpy/lib/tests/test_shape_base.py | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index 00424d55d..6e7cab3fa 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -11,6 +11,7 @@ from numpy.core.fromnumeric import product, reshape, transpose from numpy.core.multiarray import normalize_axis_index from numpy.core import overrides from numpy.core import vstack, atleast_3d +from numpy.core.shape_base import _arrays_for_stack_dispatcher from numpy.lib.index_tricks import ndindex from numpy.matrixlib.defmatrix import matrix # this raises all the right alarm bells @@ -591,7 +592,7 @@ row_stack = vstack def _column_stack_dispatcher(tup): - return tup + return _arrays_for_stack_dispatcher(tup) @array_function_dispatch(_column_stack_dispatcher) @@ -638,7 +639,7 @@ def column_stack(tup): def _dstack_dispatcher(tup): - return tup + return _arrays_for_stack_dispatcher(tup) @array_function_dispatch(_dstack_dispatcher) diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py index a7f5ca7db..e338467f9 100644 --- a/numpy/lib/tests/test_shape_base.py +++ b/numpy/lib/tests/test_shape_base.py @@ -457,6 +457,7 @@ class TestSplit(object): a = np.arange(10) assert_raises(ValueError, split, a, 3) + class TestColumnStack(object): def test_non_iterable(self): assert_raises(TypeError, column_stack, 1) @@ -481,6 +482,10 @@ class TestColumnStack(object): actual = np.column_stack((a, b)) assert_equal(actual, expected) + def test_generator(self): + with assert_warns(FutureWarning): + column_stack((np.arange(3) for _ in range(2))) + class TestDstack(object): def test_non_iterable(self): @@ -514,6 +519,10 @@ class TestDstack(object): desired = np.array([[[1, 1], [2, 2]]]) assert_array_equal(res, desired) + def test_generator(self): + with assert_warns(FutureWarning): + dstack((np.arange(3) for _ in range(2))) + # array_split has more comprehensive test of splitting. # only do simple test on hsplit, vsplit, and dsplit |
