diff options
author | Melissa Weber Mendonça <melissawm@gmail.com> | 2021-10-18 09:23:11 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 09:23:11 -0300 |
commit | f4ef0fd5d97afc7788c46eb51889e90623f5577e (patch) | |
tree | d0a5668ed4fa85014d90a2ccebc8a2d0477364b0 /numpy/lib/function_base.py | |
parent | df5c66c98144f8364f1a0c11a35419f3dfc0970d (diff) | |
parent | 3b57355559357460d31862299829536f065e7a8b (diff) | |
download | numpy-f4ef0fd5d97afc7788c46eb51889e90623f5577e.tar.gz |
Merge pull request #20123 from rossbar/doc/np-iterable-0d-arrays
DOC: Add note to iterable docstring about 0d arrays.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index ca5ef62ae..84128e4f0 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -268,6 +268,19 @@ def iterable(y): >>> np.iterable(2) False + Notes + ----- + In most cases, the results of ``np.iterable(obj)`` are consistent with + ``isinstance(obj, collections.abc.Iterable)``. One notable exception is + the treatment of 0-dimensional arrays:: + + >>> from collections.abc import Iterable + >>> a = np.array(1.0) # 0-dimensional numpy array + >>> isinstance(a, Iterable) + True + >>> np.iterable(a) + False + """ try: iter(y) |