Skip to content

Commit f4ef0fd

Browse files
authored
Merge pull request numpy#20123 from rossbar/doc/np-iterable-0d-arrays
DOC: Add note to iterable docstring about 0d arrays.
2 parents df5c66c + 3b57355 commit f4ef0fd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

numpy/lib/function_base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,19 @@ def iterable(y):
268268
>>> np.iterable(2)
269269
False
270270
271+
Notes
272+
-----
273+
In most cases, the results of ``np.iterable(obj)`` are consistent with
274+
``isinstance(obj, collections.abc.Iterable)``. One notable exception is
275+
the treatment of 0-dimensional arrays::
276+
277+
>>> from collections.abc import Iterable
278+
>>> a = np.array(1.0) # 0-dimensional numpy array
279+
>>> isinstance(a, Iterable)
280+
True
281+
>>> np.iterable(a)
282+
False
283+
271284
"""
272285
try:
273286
iter(y)

0 commit comments

Comments
 (0)