From 3b57355559357460d31862299829536f065e7a8b Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Fri, 15 Oct 2021 22:49:48 -0700 Subject: Add note to iterable docstring about 0d arrays. Co-authored-by: Sebastian Berg --- numpy/lib/function_base.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'numpy/lib/function_base.py') 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) -- cgit v1.2.1