Skip to content
Browse files

Merge pull request #7202 from madphysicist/iterable-bool-return

MAINT: Made `iterable` return a boolean
  • Loading branch information...
2 parents 920c527 + 4576343 commit 47b6c2b8bacb510cac62d490c159ec116080d1d0 @njsmith njsmith committed
Showing with 8 additions and 8 deletions.
  1. +8 −8 numpy/lib/function_base.py
View
16 numpy/lib/function_base.py
@@ -56,24 +56,24 @@ def iterable(y):
Returns
-------
- b : {0, 1}
- Return 1 if the object has an iterator method or is a sequence,
- and 0 otherwise.
+ b : bool
+ Return ``True`` if the object has an iterator method or is a
+ sequence and ``False`` otherwise.
Examples
--------
>>> np.iterable([1, 2, 3])
- 1
+ True
>>> np.iterable(2)
- 0
+ False
"""
try:
iter(y)
- except:
- return 0
- return 1
+ except TypeError:
+ return False
+ return True
def _hist_optim_numbins_estimator(a, estimator):

0 comments on commit 47b6c2b

Please sign in to comment.
Something went wrong with that request. Please try again.