summaryrefslogtreecommitdiff
path: root/numpy/core/shape_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/shape_base.py')
-rw-r--r--numpy/core/shape_base.py33
1 files changed, 10 insertions, 23 deletions
diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py
index c5e0ad475..250fffd42 100644
--- a/numpy/core/shape_base.py
+++ b/numpy/core/shape_base.py
@@ -204,19 +204,15 @@ def atleast_3d(*arys):
return res
-def _arrays_for_stack_dispatcher(arrays, stacklevel=4):
- if not hasattr(arrays, '__getitem__') and hasattr(arrays, '__iter__'):
- warnings.warn('arrays to stack must be passed as a "sequence" type '
- 'such as list or tuple. Support for non-sequence '
- 'iterables such as generators is deprecated as of '
- 'NumPy 1.16 and will raise an error in the future.',
- FutureWarning, stacklevel=stacklevel)
- return ()
- return arrays
+def _arrays_for_stack_dispatcher(arrays):
+ if not hasattr(arrays, "__getitem__"):
+ raise TypeError('arrays to stack must be passed as a "sequence" type '
+ 'such as list or tuple.')
+
+ return tuple(arrays)
-def _vhstack_dispatcher(tup, *,
- dtype=None, casting=None):
+def _vhstack_dispatcher(tup, *, dtype=None, casting=None):
return _arrays_for_stack_dispatcher(tup)
@@ -234,6 +230,8 @@ def vstack(tup, *, dtype=None, casting="same_kind"):
and r/g/b channels (third axis). The functions `concatenate`, `stack` and
`block` provide more general stacking and concatenation operations.
+ ``np.row_stack`` is an alias for `vstack`. They are the same function.
+
Parameters
----------
tup : sequence of ndarrays
@@ -285,9 +283,6 @@ def vstack(tup, *, dtype=None, casting="same_kind"):
[6]])
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # raise warning if necessary
- _arrays_for_stack_dispatcher(tup, stacklevel=2)
arrs = atleast_2d(*tup)
if not isinstance(arrs, list):
arrs = [arrs]
@@ -354,10 +349,6 @@ def hstack(tup, *, dtype=None, casting="same_kind"):
[3, 6]])
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # raise warning if necessary
- _arrays_for_stack_dispatcher(tup, stacklevel=2)
-
arrs = atleast_1d(*tup)
if not isinstance(arrs, list):
arrs = [arrs]
@@ -370,7 +361,7 @@ def hstack(tup, *, dtype=None, casting="same_kind"):
def _stack_dispatcher(arrays, axis=None, out=None, *,
dtype=None, casting=None):
- arrays = _arrays_for_stack_dispatcher(arrays, stacklevel=6)
+ arrays = _arrays_for_stack_dispatcher(arrays)
if out is not None:
# optimize for the typical case where only arrays is provided
arrays = list(arrays)
@@ -449,10 +440,6 @@ def stack(arrays, axis=0, out=None, *, dtype=None, casting="same_kind"):
[3, 6]])
"""
- if not overrides.ARRAY_FUNCTION_ENABLED:
- # raise warning if necessary
- _arrays_for_stack_dispatcher(arrays, stacklevel=2)
-
arrays = [asanyarray(arr) for arr in arrays]
if not arrays:
raise ValueError('need at least one array to stack')