summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/shape_base.py8
-rw-r--r--numpy/core/tests/test_shape_base.py2
2 files changed, 6 insertions, 4 deletions
diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py
index 4cb7a30f4..22ce47162 100644
--- a/numpy/core/shape_base.py
+++ b/numpy/core/shape_base.py
@@ -207,12 +207,12 @@ def atleast_3d(*arys):
def _arrays_for_stack_dispatcher(arrays, stacklevel=4):
- if isinstance(arrays, types.GeneratorType):
- warnings.warn('arrays to stack should be passed as a sequence, not a '
- 'generator. Support for generators is deprecated as of '
+ if hasattr(arrays, '__iter__') and not hasattr(arrays, '__getitem__'):
+ warnings.warn('arrays to stack must be passed as a sequence. Support '
+ 'for non-sequence iterables is deprecated as of '
'NumPy 1.16 and will raise an error in the future. '
'Note also that dispatch with __array_function__ is not '
- 'supported when passing arrays as a generator.',
+ 'supported when arrays are not provided as a sequence.',
FutureWarning, stacklevel=stacklevel)
return ()
return arrays
diff --git a/numpy/core/tests/test_shape_base.py b/numpy/core/tests/test_shape_base.py
index 70d217c91..0aebe54d0 100644
--- a/numpy/core/tests/test_shape_base.py
+++ b/numpy/core/tests/test_shape_base.py
@@ -158,6 +158,8 @@ class TestHstack(object):
def test_generator(self):
with assert_warns(FutureWarning):
hstack((np.arange(3) for _ in range(2)))
+ with assert_warns(FutureWarning):
+ hstack(map(lambda x: x, np.ones((3, 2))))
class TestVstack(object):